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.Cursor;
- 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.Vector;
-
- public class IndexPane extends Panel implements DialogDoneTarget, Runnable {
- protected Applet m_applet;
- protected Vector m_vSecondaryEntries = new Vector();
- protected List m_list;
- protected List m_listHolder;
- protected IndexTree m_forapplelistHolder;
- protected IndexTree m_forapplelist;
- protected TextField m_tfEdit = new TextField();
- protected Button m_btnDisplay = new Button(ResourceLib.GetRes("Display"));
- protected IndexSecondaryDialog m_dlgSecondary;
- protected int m_nSelectedIndex = -1;
- protected Panel m_pnlEditArea = new Panel();
- protected Label m_lblEditArea = new Label(ResourceLib.GetRes("IndexInputPrompt"));
- 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_bMacOS = false;
- protected boolean m_bUseForAppleList = false;
- private BsscHelpRedirector m_rd = null;
- int m_bResearch = 1;
- private Object m_Cursor = null;
- private LayoutManager m_layout;
- private int[] m_charorder = null;
- Thread m_textChangedThread = null;
-
- public boolean gotFocus(Event var1, Object var2) {
- if (this.m_bUseForAppleList) {
- if (var1.target != this.m_tfEdit && var1.target != this.m_forapplelist && var1.target != this.m_btnDisplay) {
- this.m_tfEdit.requestFocus();
- }
- } else if (var1.target != this.m_tfEdit && var1.target != this.m_list && var1.target != this.m_btnDisplay) {
- this.m_tfEdit.requestFocus();
- }
-
- return true;
- }
-
- public void HideList() {
- if (this.m_bUseForAppleList) {
- ((Container)this).add("Center", this.m_forapplelistHolder);
- this.m_forapplelistHolder.show(true);
- this.m_forapplelist.show(false);
- } else {
- ((Container)this).add("Center", this.m_listHolder);
- this.m_listHolder.show(true);
- this.m_list.show(false);
- }
-
- ((Container)this).validate();
- }
-
- public IndexTree getForAppleList() {
- return this.m_forapplelistHolder;
- }
-
- public void MoveSelectionDown() {
- }
-
- public void dialogDone() {
- this.m_dlgSecondary = null;
- }
-
- public IndexPane(Applet var1, BsscHelpRedirector var2) {
- this.m_applet = var1;
- String var3 = ResourceLib.GetRes("langorder");
- if (var3 != null) {
- this.m_charorder = new int[256];
- int var4 = 0;
- int var5 = var3.indexOf(44, var4);
-
- for(int var6 = 0; var5 != -1; var5 = var3.indexOf(44, var4)) {
- String var7 = var3.substring(var4, var5);
- if (var7 != null) {
- this.m_charorder[var6] = Integer.parseInt(var7);
- ++var6;
- }
-
- var4 = var5 + 1;
- }
- }
-
- this.m_rd = var2;
-
- try {
- if (System.getProperty("os.name").startsWith("MacOS")) {
- this.m_bMacOS = true;
- }
-
- 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")) {
- if (System.getProperty("java.version").equalsIgnoreCase("1.02")) {
- this.m_bUseForAppleList = true;
- }
-
- this.m_bIsNSWin32 = true;
- } else if (System.getProperty("os.name").startsWith("Mac")) {
- this.m_bUseForAppleList = true;
- }
- } 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_forapplelist = new IndexTree(this);
- this.m_forapplelistHolder = new IndexTree((IndexPane)null);
- this.m_forapplelistHolder.addItem(ResourceLib.GetRes("LoadingIndex"));
- } else {
- this.m_list = new List();
- this.m_listHolder = new List();
- this.m_listHolder.addItem(ResourceLib.GetRes("LoadingIndex"));
- this.m_listHolder.setBackground(Color.white);
- }
-
- this.m_pnlEditArea.setLayout(this.m_layEditArea);
- this.m_pnlEditArea.add("North", this.m_lblEditArea);
- this.m_pnlEditArea.add("Center", this.m_tfEdit);
- this.m_layout = new BorderLayout(2, 2);
- ((Container)this).setLayout(this.m_layout);
- if (!this.m_bUseForAppleList) {
- this.m_list.setBackground(Color.white);
- }
-
- int var12 = BsscFontFixPatch.GetFontSize();
- if (!this.m_bUseForAppleList) {
- this.m_list.setFont(new Font(BsscFontFixPatch.GetFontName(), 0, var12));
- }
-
- this.m_tfEdit.setFont(new Font(BsscFontFixPatch.GetFontName(), 0, var12));
- this.m_btnDisplay.setFont(new Font(BsscFontFixPatch.GetFontName(), 0, var12));
- if (this.m_bUseForAppleList) {
- ((Container)this).add("Center", this.m_forapplelistHolder);
- } else {
- ((Container)this).add("North", this.m_pnlEditArea);
- ((Container)this).add("Center", this.m_listHolder);
- ((Container)this).add("South", this.m_btnDisplay);
- }
-
- this.m_tfEdit.requestFocus();
- }
-
- public void add(String var1, Vector var2) {
- if (this.m_bUseForAppleList) {
- this.m_forapplelist.addItem(var1);
- } else {
- this.m_list.addItem(var1);
- }
-
- this.m_vSecondaryEntries.addElement(var2);
- }
-
- public boolean mouseUp(Event var1, int var2, int var3) {
- return super.mouseUp(var1, var2, var3);
- }
-
- private int compareString(String var1, String var2) {
- if (this.m_charorder == null) {
- String var5 = var1.toLowerCase();
- String var4 = var2.toLowerCase();
- return var5.compareTo(var4);
- } else {
- for(int var3 = 0; var3 < var1.length() && var3 < var2.length(); ++var3) {
- if (this.m_charorder[var1.charAt(var3)] < this.m_charorder[var2.charAt(var3)]) {
- return -1;
- }
-
- if (this.m_charorder[var1.charAt(var3)] > this.m_charorder[var2.charAt(var3)]) {
- return 1;
- }
- }
-
- if (var1.length() < var2.length()) {
- return -1;
- } else {
- return var1.length() > var2.length() ? 1 : 0;
- }
- }
- }
-
- public List getList() {
- return this.m_list;
- }
-
- public void MoveSelectionPageDown() {
- }
-
- public int FindBaseKeywordForAppleList(int var1, int var2) {
- while(var1 > 0 && var2 < 0 || var1 < this.m_forapplelist.countItems() - 1 && var2 > 0) {
- if (this.m_forapplelist.getItem(var1).charAt(0) != ' ') {
- return var1;
- }
-
- var1 += var2;
- }
-
- return var1;
- }
-
- public void ShowList() {
- if (this.m_bUseForAppleList) {
- ((Container)this).add("North", this.m_pnlEditArea);
- ((Container)this).add("Center", this.m_forapplelist);
- ((Container)this).add("South", this.m_btnDisplay);
- this.m_forapplelist.show(true);
- this.m_forapplelistHolder.show(false);
- } else {
- if (!System.getProperty("java.vendor").startsWith("Netscape")) {
- ((Container)this).add("North", this.m_pnlEditArea);
- }
-
- ((Container)this).add("Center", this.m_list);
- ((Container)this).add("South", this.m_btnDisplay);
- this.m_list.show(true);
- this.m_listHolder.show(false);
- }
-
- ((Container)this).validate();
- }
-
- public TextField getEditBox() {
- return this.m_tfEdit;
- }
-
- public boolean keyUp(Event var1, int var2) {
- if ((var1.target == this.m_forapplelist || var1.target == this.m_list) && System.getProperty("java.version").equals("1.1") && System.getProperty("java.vendor").startsWith("Microsoft") && var1.key == 10) {
- this.action(var1, var1.target);
- return true;
- } else if (var1.target == this.m_tfEdit && System.getProperty("java.version").equals("1.1") && System.getProperty("java.vendor").startsWith("Microsoft") && var1.key == 10) {
- this.action(var1, var1.target);
- return true;
- } else {
- if (this.m_bIsNSWin16) {
- var2 &= 255;
- }
-
- boolean var3 = super.keyUp(var1, var2);
- if ((var2 == 8 || var2 >= 32 && var2 <= 126) && var1.target == this.m_tfEdit) {
- try {
- this.textChanged();
- if (var1.target == this.m_tfEdit) {
- this.m_tfEdit.requestFocus();
- }
- } finally {
- ;
- }
- }
-
- return var3;
- }
- }
-
- public boolean GetUseForAppleListFlag() {
- return this.m_bUseForAppleList;
- }
-
- public void ResetCursor() {
- if (!System.getProperty("java.version").startsWith("1.0") && (System.getProperty("java.vendor").indexOf("Netscape") == -1 || !System.getProperty("java.version").startsWith("1.1.2"))) {
- if (this.m_Cursor != null) {
- try {
- ((Component)this).setCursor((Cursor)this.m_Cursor);
- } catch (Exception var1) {
- }
-
- this.m_Cursor = null;
- }
-
- }
- }
-
- public void gotoSelectedIndex() {
- int var1 = -1;
- if (this.m_bUseForAppleList) {
- var1 = this.m_forapplelist.getSelectedIndex();
- } else {
- var1 = this.m_list.getSelectedIndex();
- }
-
- if (var1 != -1) {
- if (((Vector)this.m_vSecondaryEntries.elementAt(var1)).size() == 1) {
- IndexSecondaryEntry var2 = (IndexSecondaryEntry)((Vector)this.m_vSecondaryEntries.elementAt(var1)).elementAt(0);
- if (var2.see_also != null) {
- for(int var7 = 0; var7 < this.m_vSecondaryEntries.size(); ++var7) {
- if (((Vector)this.m_vSecondaryEntries.elementAt(var7)).size() == 1) {
- IndexSecondaryEntry var9 = (IndexSecondaryEntry)((Vector)this.m_vSecondaryEntries.elementAt(var7)).elementAt(0);
- if (var9.name.equals(var2.see_also)) {
- if (this.m_bUseForAppleList) {
- this.m_forapplelist.select(var7);
- if (var7 > 0) {
- this.m_forapplelist.setTopIndex(var7 - 1);
- } else {
- this.m_forapplelist.setTopIndex(var7);
- }
-
- this.gotoSelectedIndex();
- return;
- }
-
- if (this.m_list.getVisibleIndex() != var7) {
- this.m_list.makeVisible(this.m_forapplelist.countItems() - 1);
- if (var7 > 0) {
- this.m_list.makeVisible(var7 - 1);
- } else {
- this.m_list.makeVisible(var7);
- }
- }
-
- this.m_list.select(var7);
- this.gotoSelectedIndex();
- return;
- }
- }
- }
-
- } else {
- try {
- URL var3 = URLFileHandler.makeURL(this.m_applet.getDocumentBase(), var2.local, var2.url);
- String var4 = var3.toString();
- if (var4.indexOf("file:/\\\\") == 0) {
- var4 = "file://" + var4.substring(8);
- var3 = new URL(var4);
- }
-
- this.m_rd.showDoc(var3, var2.frame);
- } catch (MalformedURLException var5) {
- ((Throwable)var5).printStackTrace();
- }
- }
- } else {
- if (this.m_dlgSecondary != null) {
- this.m_dlgSecondary.closeDialog();
- this.m_dlgSecondary = null;
- }
-
- this.m_dlgSecondary = new IndexSecondaryDialog(this.m_applet, (Vector)this.m_vSecondaryEntries.elementAt(var1), this, this.m_rd);
- this.m_dlgSecondary.showTopic();
- this.m_dlgSecondary.getList().requestFocus();
- }
- }
- }
-
- public void SetWaitCursor() {
- if (!System.getProperty("java.version").startsWith("1.0") && (System.getProperty("java.vendor").indexOf("Netscape") == -1 || !System.getProperty("java.version").startsWith("1.1.2"))) {
- try {
- this.m_Cursor = ((Component)this).getCursor();
- ((Component)this).setCursor(new Cursor(3));
- } catch (Exception var1) {
- }
- }
- }
-
- public int FindBaseKeyword(int var1, int var2) {
- while(var1 > 0 && var2 < 0 || var1 < this.m_list.countItems() - 1 && var2 > 0) {
- if (this.m_list.getItem(var1).charAt(0) != ' ') {
- return var1;
- }
-
- var1 += var2;
- }
-
- return var1;
- }
-
- 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) {
- this.gotoSelectedIndex();
- return true;
- }
-
- public void run() {
- try {
- while(true) {
- if (this.m_bResearch <= 0) {
- try {
- Thread.sleep(100L);
- } catch (InterruptedException var8) {
- ((Throwable)var8).printStackTrace();
- }
- } else {
- String var1 = this.m_tfEdit.getText().toUpperCase();
- int var2 = var1.length();
- if (var2 > 0) {
- if (this.m_bUseForAppleList) {
- int var3 = 0;
- int var4 = this.FindBaseKeywordForAppleList(this.m_forapplelist.countItems() - 1, -1);
-
- int var5;
- for(var5 = this.FindBaseKeywordForAppleList((this.m_forapplelist.countItems() - 1) / 2, -1); var3 < var4; var5 = this.FindBaseKeywordForAppleList((var3 + var4) / 2, -1)) {
- String var6 = this.m_forapplelist.getItem(var5).toUpperCase();
- int var7 = this.compareString(var6, var1);
- if (var7 > 0) {
- var4 = var5;
- } else if (var7 < 0) {
- var3 = this.FindBaseKeywordForAppleList(var5 + 1, 1);
- } else {
- var3 = var5;
- var4 = var5;
- }
- }
-
- while(var5 > 0) {
- String var13 = this.m_forapplelist.getItem(var5 - 1);
- int var16 = this.compareString(var13, var1);
- if (var16 != 0) {
- break;
- }
-
- --var5;
- }
-
- this.m_forapplelist.getItem(var5).toUpperCase();
- if (var5 > this.m_forapplelist.countItems() - 1) {
- var5 = this.m_forapplelist.countItems() - 1;
- }
-
- if (var5 < 0) {
- var5 = 0;
- }
-
- if (var5 != this.m_nSelectedIndex) {
- this.m_forapplelist.makeVisible(this.m_forapplelist.countItems() - 1);
- if (var5 > 0) {
- this.m_forapplelist.makeVisible(var5 - 1);
- } else {
- this.m_forapplelist.makeVisible(var5);
- }
-
- this.m_forapplelist.getVisibleIndex();
- this.m_forapplelist.select(var5);
- this.m_nSelectedIndex = var5;
- }
-
- this.m_applet.showStatus(this.m_forapplelist.getSelectedItem());
- } else {
- int var10 = 0;
- int var11 = this.FindBaseKeyword(this.m_list.countItems() - 1, -1);
-
- int var12;
- for(var12 = this.FindBaseKeyword((this.m_list.countItems() - 1) / 2, -1); var10 < var11; var12 = this.FindBaseKeyword((var10 + var11) / 2, -1)) {
- String var14 = this.m_list.getItem(var12).toUpperCase();
- int var17 = this.compareString(var14, var1);
- if (var17 > 0) {
- var11 = var12;
- } else if (var17 < 0) {
- var10 = this.FindBaseKeyword(var12 + 1, 1);
- } else {
- var10 = var12;
- var11 = var12;
- }
- }
-
- while(var12 > 0) {
- String var15 = this.m_list.getItem(var12 - 1);
- int var18 = this.compareString(var15, var1);
- if (var18 != 0) {
- break;
- }
-
- --var12;
- }
-
- this.m_list.getItem(var12).toUpperCase();
- if (var12 > this.m_list.countItems() - 1) {
- var12 = this.m_list.countItems() - 1;
- }
-
- if (var12 < 0) {
- var12 = 0;
- }
-
- if (var12 != this.m_nSelectedIndex) {
- this.m_list.makeVisible(this.m_list.countItems() - 1);
- if (var12 > 0) {
- this.m_list.makeVisible(var12 - 1);
- } else {
- this.m_list.makeVisible(var12);
- }
-
- this.m_list.getVisibleIndex();
- this.m_list.select(var12);
- this.m_nSelectedIndex = var12;
- }
-
- this.m_applet.showStatus(this.m_list.getSelectedItem());
- }
- }
-
- this.m_bResearch += -1;
- }
- }
- } catch (Exception var9) {
- ((Throwable)var9).printStackTrace();
- }
- }
-
- public boolean handleEvent(Event var1) {
- if (var1.id == 401 && var1.key == 9 && System.getProperty("java.vendor").startsWith("Netscape") && System.getProperty("java.version").startsWith("1.1.2")) {
- ((Component)this).nextFocus();
- return true;
- } else if (System.getProperty("java.version").startsWith("1.1.5") && this.m_bIsNSWin32 && var1.id == 401 && var1.key == 10 && var1.target == this.m_btnDisplay) {
- 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) {
- if (var1.id == 701 && this.m_list.getSelectedIndex() != this.m_nSelectedIndex) {
- this.m_nSelectedIndex = this.m_list.getSelectedIndex();
- String var2 = this.m_list.getItem(this.m_nSelectedIndex);
- if (var2 != null) {
- var2 = var2.trim();
- this.m_tfEdit.setText(var2);
- this.m_applet.showStatus(var2);
- }
- }
- } else if (var1.target == this.m_tfEdit && var1.id == 401 && var1.key == 10 && (!System.getProperty("java.version").equals("1.1") || !System.getProperty("java.vendor").startsWith("Microsoft")) && !System.getProperty("java.vendor").startsWith("Netscape")) {
- this.action(var1, var1.target);
- return true;
- }
-
- return super.handleEvent(var1);
- }
- }
-
- public void textChanged() {
- if (this.m_textChangedThread == null) {
- this.m_textChangedThread = new Thread(this);
- this.m_textChangedThread.setPriority(4);
- this.m_textChangedThread.start();
- } else {
- ++this.m_bResearch;
- }
- }
-
- public void MoveSelectionUp() {
- }
-
- public void MoveSelectionPageUp() {
- }
-
- public boolean keyDown(Event var1, int var2) {
- if ((var1.target == this.m_forapplelist || var1.target == this.m_list) && (!System.getProperty("java.version").equals("1.1") || !System.getProperty("java.vendor").startsWith("Microsoft")) && var1.key == 10) {
- this.action(var1, var1.target);
- return true;
- } else {
- return super.keyDown(var1, var2);
- }
- }
- }
-