home *** CD-ROM | disk | FTP | other *** search
Wrap
import BsscXML.BsscXML; import XMLConsumer.Consumer; import XMLConsumer.Project; import hhapplet.BsscHelpCommandAdapter; import hhapplet.BsscHelpRedirector; import hhapplet.ButtonPushEvent; import hhapplet.ButtonPushEventListener; import hhapplet.CanvasButton; import hhapplet.FtsView; import hhapplet.FtsViewSkin; import hhapplet.GloViewSkin; import hhapplet.GlossaryView; import hhapplet.ImageCache; import hhapplet.IndexView; import hhapplet.IndexViewSkin; import hhapplet.PaneSetting; import hhapplet.ResourceLib; import hhapplet.TabButton; import hhapplet.TabManagerAdaper; import hhapplet.TabPanel; import hhapplet.TocView; import hhapplet.TocViewSkin; import hhapplet.URLFileHandler; import java.applet.Applet; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Event; import java.awt.Graphics; import java.awt.LayoutManager; import java.awt.Panel; import java.awt.Rectangle; import java.net.URL; import java.util.Enumeration; import java.util.Vector; import netscape.javascript.JSObject; public class WebHelp extends Applet implements ButtonPushEventListener, BsscHelpCommandAdapter, TabManagerAdaper, Runnable { private static final String STR_APPLET_ID = "WebHelp Applet Version 5.00.000"; private static final String STR_COPYRIGHT = "Copyright (c) 1998-2001 eHelp Corporation. All rights reserved."; private boolean m_bShowTab = true; private String m_strProjectFile = null; private TocView m_tocView = null; private IndexView m_indexView = null; private FtsView m_ftsView = null; private GlossaryView m_gloView = null; private Panel m_pnlNav = null; private TabPanel m_pnlTabs = null; private CardLayout m_clLayout = null; private TabButton[] m_abtns; private CommandBuffer m_commandBuffer; private String m_sLangId = ""; private boolean m_bMustHaveSize = false; boolean m_bCanAccessJSObject = false; private boolean m_bCanAccessJSObjectChecked = false; private Thread m_CommandThread = null; private Vector m_vProjects; private PaneSetting m_tocPaneSetting; private PaneSetting m_idxPaneSetting; private PaneSetting m_ftsPaneSetting; private PaneSetting m_gloPaneSetting; private int m_nFirstPane; private static final int m_nMaxPanes = 4; public void stop() { System.out.println("!!!Applet Stop!!!"); if (System.getProperty("java.vendor").indexOf("Netscape") != -1 && this.CanQueryHeighAndWidthForNS()) { try { JSObject var1 = JSObject.getWindow(this); var1.setMember("gbLoading", "Phase1"); } catch (Exception var3) { ((Throwable)var3).printStackTrace(); } } try { if (this.m_CommandThread != null) { new WhCommand("Quit", (String)null, (String)null); this.m_CommandThread.stop(); } System.gc(); Runtime.getRuntime().gc(); } catch (Exception var2) { ((Throwable)var2).printStackTrace(); } } public boolean gotFocus(Event var1, Object var2) { ((Component)this).nextFocus(); return true; } public void notifyButtonPushEvent(ButtonPushEvent var1) { if (this.m_tocPaneSetting != null && var1.getSource() == this.m_abtns[this.m_tocPaneSetting.getIndex()]) { this.DoContents(); } else if (this.m_idxPaneSetting != null && var1.getSource() == this.m_abtns[this.m_idxPaneSetting.getIndex()]) { this.DoIndex(); } else if (this.m_ftsPaneSetting != null && var1.getSource() == this.m_abtns[this.m_ftsPaneSetting.getIndex()]) { this.DoSearch(""); } else { if (this.m_gloPaneSetting != null && var1.getSource() == this.m_abtns[this.m_gloPaneSetting.getIndex()]) { this.DoGlossary(); } } } private void activeTabButton(int var1) { int var2 = 0; do { if (this.m_abtns[var2] != null) { if (var2 != var1) { this.m_abtns[var2].disactive(); if (var2 == var1 - 1) { this.m_abtns[var2].SetDrawRight(false); } else { this.m_abtns[var2].SetDrawRight(true); } if (var2 == var1 + 1) { this.m_abtns[var2].SetDrawLeft(false); } else { this.m_abtns[var2].SetDrawLeft(true); } } else { this.m_abtns[var2].active(); } this.m_abtns[var2].repaint(0L); } ++var2; } while(var2 < 4); } public boolean CanQueryHeighAndWidthForNS() { if (this.m_bCanAccessJSObjectChecked) { return this.m_bCanAccessJSObject; } else { this.m_bCanAccessJSObjectChecked = true; return this._checkAccess(); } } public void start() { System.out.println("!!!Applet Start!!!"); try { this.m_commandBuffer = new CommandBuffer(); if (this.m_bMustHaveSize) { this.checkSize(); } this.m_CommandThread = new Thread(this); this.m_CommandThread.start(); } catch (Exception var2) { ((Throwable)var2).printStackTrace(); } if (System.getProperty("java.vendor").indexOf("Netscape") == -1) { this.myrun(); } } public String getAppletInfo() { return "WebHelp Applet Version 5.00.000" + "\r\n" + "Copyright (c) 1998-2001 eHelp Corporation. All rights reserved."; } private void DoGlossary() { if (this.m_gloPaneSetting != null) { this.activeTabButton(this.m_gloPaneSetting.getIndex()); if (this.m_pnlNav == null) { this.m_clLayout = new CardLayout(); this.m_pnlNav = new Panel(); this.m_pnlNav.setLayout(this.m_clLayout); ((Container)this).add("Center", this.m_pnlNav); } this.m_bMustHaveSize = true; if (this.m_gloView == null) { GloViewSkin var1 = (GloViewSkin)this.m_gloPaneSetting.getViewSkin(); this.m_gloView = new GlossaryView(this.m_vProjects, var1); this.m_pnlNav.add(ResourceLib.GetRes("Glossary"), this.m_gloView); ((Applet)this).showStatus(ResourceLib.GetRes("LoadingGlossary")); } this.m_clLayout.show(this.m_pnlNav, ResourceLib.GetRes("Glossary")); ((Component)this).repaint(); this.RepaintTabs(); if (this.m_gloView != null) { this.m_gloView.requestFocus(); } } } public void reshape(int var1, int var2, int var3, int var4) { System.out.println("!!!Applet Reshape!!!"); try { if (System.getProperty("java.vendor").startsWith("Netscape") && (System.getProperty("os.name").startsWith("Windows") || System.getProperty("os.name").startsWith("Mac"))) { if (this.CanQueryHeighAndWidthForNS()) { WebHelp$JavaScriptAccess var5 = new WebHelp$JavaScriptAccess(this, this); var4 = var5.GetHeight(var4); var3 = var5.GetWidth(var3); if (!this.m_bShowTab) { try { if (System.getProperty("java.vendor").indexOf("Netscape") != -1) { ((Component)this).getParent().reshape(var1, var2, var3, var4); } } catch (Exception var7) { ((Throwable)var7).printStackTrace(); } } super.reshape(var1, var2, var3, var4); ((Container)this).validate(); } else { super.reshape(var1, var2, var3, var4); } } else { super.reshape(var1, var2, var3, var4); ((Container)this).validate(); } } catch (Exception var8) { ((Throwable)var8).printStackTrace(); } } private void DoNavPane() { ((Component)this).setBackground(new Color(192, 192, 192)); ((Container)this).setLayout(new BorderLayout()); this.m_strProjectFile = ((Applet)this).getParameter("ProjectFile"); if (this.m_strProjectFile != null && this.m_strProjectFile.length() > 0) { this.loadProject(this.m_strProjectFile); } String var1 = ((Applet)this).getParameter("HideTabs"); if (var1 != null && var1.toUpperCase().compareTo("TRUE") == 0) { this.m_bShowTab = false; } else { this.m_bShowTab = true; } Object var2 = null; String var9 = ((Applet)this).getParameter("ContentsTab"); if (var9 == null) { var9 = ResourceLib.GetRes("Contents"); } Object var3 = null; String var10 = ((Applet)this).getParameter("IndexTab"); if (var10 == null) { var10 = ResourceLib.GetRes("Index"); } Object var4 = null; String var11 = ((Applet)this).getParameter("SearchTab"); if (var11 == null) { var11 = ResourceLib.GetRes("Search"); } Object var5 = null; String var12 = ((Applet)this).getParameter("GlossaryTab"); if (var12 == null) { var12 = ResourceLib.GetRes("Glossary"); } this.m_pnlTabs = null; this.m_pnlTabs = new TabPanel(); this.m_pnlTabs.setLayout((LayoutManager)null); this.m_abtns = new TabButton[4]; if (this.m_tocPaneSetting != null) { TabButton var6 = new TabButton(var9, this); ((CanvasButton)var6).addButtonPushEventListener(this); if (4 > this.m_tocPaneSetting.getIndex()) { this.m_abtns[this.m_tocPaneSetting.getIndex()] = var6; } } if (this.m_idxPaneSetting != null) { TabButton var13 = new TabButton(var10, this); ((CanvasButton)var13).addButtonPushEventListener(this); if (4 > this.m_idxPaneSetting.getIndex()) { this.m_abtns[this.m_idxPaneSetting.getIndex()] = var13; } } if (this.m_ftsPaneSetting != null) { TabButton var14 = new TabButton(var11, this); ((CanvasButton)var14).addButtonPushEventListener(this); if (4 > this.m_ftsPaneSetting.getIndex()) { this.m_abtns[this.m_ftsPaneSetting.getIndex()] = var14; } } if (this.m_gloPaneSetting != null) { TabButton var15 = new TabButton(var12, this); ((CanvasButton)var15).addButtonPushEventListener(this); if (4 > this.m_gloPaneSetting.getIndex()) { this.m_abtns[this.m_gloPaneSetting.getIndex()] = var15; } } int var16 = 0; do { if (this.m_abtns[var16] != null) { this.m_pnlTabs.add(this.m_abtns[var16]); } ++var16; } while(var16 < 4); if (this.m_bShowTab) { ((Container)this).add("North", this.m_pnlTabs); } Rectangle var17 = ((Component)this).bounds(); int var7 = 1; int var8 = 0; do { if (this.m_abtns[var8] != null) { this.rods_reshape(this.m_abtns[var8], var7, var17.y, this.m_abtns[var8].preferredSize().width, 25); var7 += this.m_abtns[var8].bounds().width; } ++var8; } while(var8 < 4); this.rods_reshape(this.m_pnlTabs, var17.x, var17.y, var17.width, 28); this.m_pnlTabs.requestFocus(); var8 = 0; do { if (this.m_abtns[var8] != null) { this.m_abtns[var8].active(); } ++var8; } while(var8 < 4); var8 = 0; do { if (this.m_abtns[var8] != null) { this.m_abtns[var8].disactive(); } ++var8; } while(var8 < 4); if (this.m_abtns[this.m_nFirstPane] != null) { Object var20 = null; ButtonPushEvent var21 = new ButtonPushEvent(this.m_abtns[this.m_nFirstPane], 0, 0); this.notifyButtonPushEvent(var21); } } public void Command(String var1, String var2) { this.Command(var1, var2, (String)null); } public synchronized void Command(String var1, String var2, String var3) { if (this.m_CommandThread != null) { WhCommand var4 = new WhCommand(var1, var2, var3); this.m_commandBuffer.putCommand(var4); } } public void Command(String var1) { this.Command(var1, (String)null, (String)null); } public void printVMInfo() { try { System.out.println(System.getProperty("java.version")); System.out.println(System.getProperty("java.vendor")); System.out.println(System.getProperty("java.vendor.url")); System.out.println(System.getProperty("java.home")); System.out.println(System.getProperty("java.class.path")); System.out.println(System.getProperty("java.class.version")); System.out.println(System.getProperty("os.name")); System.out.println(System.getProperty("os.arch")); System.out.println(System.getProperty("os.version")); System.out.println(System.getProperty("user.name")); System.out.println(System.getProperty("user.home")); System.out.println(System.getProperty("user.dir")); } catch (Exception var2) { ((Throwable)var2).printStackTrace(); } } public void paint(Graphics var1) { System.out.println("!!!Applet paint!!!"); super.paint(var1); } public void destroy() { System.out.println("!!!Applet Destroy!!!"); try { System.gc(); Runtime.getRuntime().gc(); } catch (Exception var2) { ((Throwable)var2).printStackTrace(); } } protected void rods_reshape(Component var1, int var2, int var3, int var4, int var5) { var1.move(var2, var3); var1.resize(var4, var5); } private void DoContents() { if (this.m_tocPaneSetting != null) { this.activeTabButton(this.m_tocPaneSetting.getIndex()); if (this.m_pnlNav == null) { this.m_clLayout = new CardLayout(); this.m_pnlNav = new Panel(); this.m_pnlNav.setLayout(this.m_clLayout); ((Container)this).add("Center", this.m_pnlNav); } this.m_bMustHaveSize = true; this.RepaintTabs(); if (this.m_tocView == null) { TocViewSkin var1 = (TocViewSkin)this.m_tocPaneSetting.getViewSkin(); this.m_tocView = new TocView(this.m_vProjects, var1); this.m_pnlNav.add(ResourceLib.GetRes("Contents"), this.m_tocView); ((Applet)this).showStatus(ResourceLib.GetRes("LoadingContents")); } this.m_clLayout.show(this.m_pnlNav, ResourceLib.GetRes("Contents")); if (this.m_tocView != null) { this.m_tocView.requestFocus(); } } } public void resize(int var1, int var2) { System.out.println("!!!Applet Resize!!!"); if (System.getProperty("java.vendor").indexOf("Netscape") != -1) { if (this.CanQueryHeighAndWidthForNS()) { try { JSObject var3 = JSObject.getWindow(this); var3.setMember("gbLoading", "Phase1"); } catch (Exception var6) { ((Throwable)var6).printStackTrace(); } } } else if (System.getProperty("java.vendor").indexOf("Microsoft") != -1 && System.getProperty("java.version").startsWith("1.1")) { try { JSObject var7 = JSObject.getWindow(this); var7.setMember("gbLoading", "Phase1"); } catch (Exception var5) { ((Throwable)var5).printStackTrace(); } } try { if (this.CanQueryHeighAndWidthForNS()) { WebHelp$JavaScriptAccess var8 = new WebHelp$JavaScriptAccess(this, this); var2 = var8.GetHeight(var2); var1 = var8.GetWidth(var1); } super.resize(var1, var2); } catch (Exception var4) { ((Throwable)var4).printStackTrace(); } } public synchronized boolean checkSize() { if (((Component)this).bounds().width == 0 && ((Component)this).bounds().height == 0) { String var1 = ((Applet)this).getDocumentBase().toString(); int var2 = var1.lastIndexOf("."); String var3 = var1.substring(var2, var1.length()); var1 = var1.substring(0, var2); var1 = var1 + "f" + var3; try { URL var4 = new URL(var1); ((Applet)this).getAppletContext().showDocument(var4, "_self"); return false; } catch (Exception var5) { ((Throwable)var5).printStackTrace(); } } return true; } private void DoSearch(String var1) { if (this.m_ftsPaneSetting != null) { this.activeTabButton(this.m_ftsPaneSetting.getIndex()); if (this.m_pnlNav == null) { this.m_clLayout = new CardLayout(); this.m_pnlNav = new Panel(); this.m_pnlNav.setLayout(this.m_clLayout); ((Container)this).add("Center", this.m_pnlNav); } this.m_bMustHaveSize = true; if (this.m_ftsView == null) { FtsViewSkin var2 = (FtsViewSkin)this.m_ftsPaneSetting.getViewSkin(); this.m_ftsView = new FtsView(this.m_vProjects, var2); this.m_pnlNav.add(ResourceLib.GetRes("Search"), this.m_ftsView); ((Applet)this).showStatus(ResourceLib.GetRes("LoadingFTS")); } if (var1 != null && var1.length() != 0) { this.m_ftsView.setSearchString(var1); } this.m_clLayout.show(this.m_pnlNav, ResourceLib.GetRes("Search")); ((Component)this).repaint(); this.RepaintTabs(); if (this.m_ftsView != null) { this.m_ftsView.requestFocus(); } } } public void myrun() { try { System.gc(); Runtime.getRuntime().gc(); ImageCache.createInstance(this); BsscXML.setDocumentBase(((Applet)this).getDocumentBase()); ResourceLib.InitRes(); String var1 = ((Applet)this).getParameter("ResourceFile"); if (var1 != null) { ResourceLib.LoadResource(var1); } this.m_tocPaneSetting = ResourceLib.getPaneSetting("toc"); this.m_idxPaneSetting = ResourceLib.getPaneSetting("index"); this.m_ftsPaneSetting = ResourceLib.getPaneSetting("fts"); this.m_gloPaneSetting = ResourceLib.getPaneSetting("glossary"); this.m_nFirstPane = ResourceLib.getFirstShowPaneIndex(); String var2 = ((Applet)this).getParameter("Frame"); if (var2 == null) { var2 = "bsscright"; } BsscHelpRedirector.initRedirector(this, var2); this.DoNavPane(); ((Component)this).show(); } catch (Exception var3) { ((Throwable)var3).printStackTrace(); } } private void RepaintTabs() { if (this.m_bShowTab) { if (this.m_pnlNav != null) { this.m_pnlNav.paintAll(this.m_pnlNav.getGraphics()); } int var1 = 0; do { if (this.m_abtns[var1] != null) { this.m_abtns[var1].paint(this.m_abtns[var1].getGraphics()); } ++var1; } while(var1 < 4); } } private void DoIndex() { if (this.m_idxPaneSetting != null) { this.activeTabButton(this.m_idxPaneSetting.getIndex()); if (this.m_pnlNav == null) { this.m_clLayout = new CardLayout(); this.m_pnlNav = new Panel(); this.m_pnlNav.setLayout(this.m_clLayout); ((Container)this).add("Center", this.m_pnlNav); } this.m_bMustHaveSize = true; if (this.m_indexView == null) { IndexViewSkin var1 = (IndexViewSkin)this.m_idxPaneSetting.getViewSkin(); this.m_indexView = new IndexView(this.m_vProjects, var1); this.m_pnlNav.add(ResourceLib.GetRes("Index"), this.m_indexView); ((Applet)this).showStatus(ResourceLib.GetRes("LoadingIndex")); } this.m_clLayout.show(this.m_pnlNav, ResourceLib.GetRes("Index")); this.m_pnlNav.paintAll(this.m_pnlNav.getGraphics()); this.RepaintTabs(); if (this.m_indexView != null) { this.m_indexView.requestFocus(); } } } public boolean GoNext(Object var1) { if (this.m_pnlTabs == null) { return false; } else { for(int var2 = 0; var2 < this.m_pnlTabs.getComponentCount(); ++var2) { if (this.m_pnlTabs.getComponent(var2) == var1) { if (var2 != this.m_pnlTabs.getComponentCount() - 1) { Component var3 = this.m_pnlTabs.getComponent(var2 + 1); var3.requestFocus(); this.notifyButtonPushEvent(new ButtonPushEvent(var3, 0, 0)); return true; } return false; } } return false; } } private void DoSync(String var1, String var2) { if (this.m_tocView != null) { this.m_tocView.sync(var1, var2); } } public void run() { while(true) { try { Object var1 = null; while((var6 = this.m_commandBuffer.getCommand()) == null) { Thread.currentThread(); Thread.sleep(100L); } String var2 = var6.getName(); String var3 = var6.getParam0(); String var4 = var6.getParam1(); if (var2.equalsIgnoreCase("SyncToc")) { this.DoSync(var3, var4); } else if (var2.equalsIgnoreCase("Contents")) { this.DoContents(); } else if (var2.equalsIgnoreCase("Index")) { this.DoIndex(); } else if (var2.equalsIgnoreCase("Search")) { this.DoSearch(var3); } else if (var2.equalsIgnoreCase("Glossary")) { this.DoGlossary(); } else if (var2.equalsIgnoreCase("Quit")) { return; } } catch (Exception var5) { ((Throwable)var5).printStackTrace(); } } } public void init() { System.out.println("!!!Applet Init!!!"); if (System.getProperty("java.vendor").indexOf("Netscape") != -1) { this.myrun(); } } public boolean GoPrev(Object var1) { if (this.m_pnlTabs == null) { return false; } else { for(int var2 = 0; var2 < this.m_pnlTabs.getComponentCount(); ++var2) { if (this.m_pnlTabs.getComponent(var2) == var1) { if (var2 != 0) { Component var3 = this.m_pnlTabs.getComponent(var2 - 1); var3.requestFocus(); this.notifyButtonPushEvent(new ButtonPushEvent(var3, 0, 0)); return true; } return false; } } return false; } } public synchronized void resizeForNS(int var1, int var2) { try { if (System.getProperty("java.vendor").indexOf("Netscape") != -1) { ((Component)this).getParent().reshape(0, 0, var1, var2); } super.reshape(0, 0, var1, var2); ((Container)this).validate(); } catch (Exception var4) { ((Throwable)var4).printStackTrace(); } } private boolean _checkAccess() { if (System.getProperty("java.vendor").startsWith("Netscape") && (System.getProperty("os.name").startsWith("Windows") || System.getProperty("os.name").startsWith("Mac"))) { try { if (((Applet)this).getParameter("BrowserVersion") == null || !((Applet)this).getParameter("BrowserVersion").equalsIgnoreCase("4.6")) { JSObject.getWindow(this); this.m_bCanAccessJSObject = true; } } catch (Exception var2) { System.gc(); ((Throwable)var2).printStackTrace(); } } return this.m_bCanAccessJSObject; } public void loadProject(String var1) { try { Project.setFileName(var1); this.m_vProjects = new Vector(); URL var2 = URLFileHandler.makeURL(BsscXML.getDocumentBase(), var1, (String)null); this.m_vProjects.addElement(new Project(var2)); int var3 = 0; do { Project var4 = (Project)this.m_vProjects.elementAt(var3); try { ((Consumer)var4).process(); if (var3 == 0) { this.m_sLangId = var4.getLangId(); } else { String var5 = var4.getLangId(); if (!this.m_sLangId.equals(var5)) { System.out.println("The Project:" + ((Consumer)var4).getURL() + "is using a different language to the main project, which will cause the index and full text search functionality to be disabled for this remote project"); } } URL var15 = ((Consumer)var4).getURL(); Vector var6 = var4.getRemoteProject(); Enumeration var7 = var6.elements(); while(var7.hasMoreElements()) { Object var8 = var7.nextElement(); if (var8 instanceof String) { URL var9 = URLFileHandler.makeURL(var15, (String)var8 + var1, (String)null); boolean var10 = false; Enumeration var11 = this.m_vProjects.elements(); while(var11.hasMoreElements()) { Object var12 = var11.nextElement(); if (var12 instanceof Project && ((Project)var12).getURL().equals(var9)) { var10 = true; break; } } if (!var10) { this.m_vProjects.addElement(new Project(var9)); } } } ++var3; } catch (Exception var13) { this.m_vProjects.removeElementAt(var3); ((Throwable)var13).printStackTrace(); } } while(var3 < this.m_vProjects.size()); System.out.println("Well done!"); } catch (Exception var14) { ((Throwable)var14).printStackTrace(); } } }