home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2002 March / PCWMAR02.iso / software / windowsxp / ftgateoffice / ftgateoffice.exe / Main / webhelp.jar / hhapplet / SiteMapParserToContents.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-11-07  |  5.4 KB  |  293 lines

  1. package hhapplet;
  2.  
  3. import java.applet.Applet;
  4. import java.awt.Color;
  5. import java.awt.Image;
  6. import java.util.Vector;
  7. import sitemap.SiteMapParserOutput;
  8. import treeview.ImageSet;
  9. import treeview.SiblingChildTree;
  10. import treeview.TreeView;
  11. import treeview.TreeViewNode;
  12.  
  13. public class SiteMapParserToContents implements SiteMapParserOutput {
  14.    protected TreeViewNode root_tree = new TreeViewNode();
  15.    protected int ind = 0;
  16.    protected int real_ind = 0;
  17.    protected Vector parent_list = new Vector();
  18.    protected boolean done_a_node = false;
  19.    protected boolean in_global = true;
  20.    protected Image[] images;
  21.    // $FF: renamed from: a java.applet.Applet
  22.    protected Applet field_0;
  23.    protected TreeView m_tvTheTree = null;
  24.    protected String default_frame_name;
  25.    protected boolean use_folder_images = false;
  26.    protected String name;
  27.    protected String local;
  28.    protected String url;
  29.    protected String frame_name;
  30.    protected boolean new_topic;
  31.    private int m_nItems = 0;
  32.    protected ImageCache m_ImageCache;
  33.    protected String imageSource = null;
  34.    protected String imageSourceOpen = null;
  35.    private BsscHelpRedirector m_rd;
  36.  
  37.    public void end() {
  38.       this.getTree();
  39.       this.m_tvTheTree.setFilled(true);
  40.       this.RemoveEmptyBooks(this.m_tvTheTree.getRoot());
  41.       this.field_0.showStatus(ResourceLib.GetRes("CompletingContents"));
  42.       this.m_tvTheTree.layout();
  43.       this.m_tvTheTree.ResetCursor();
  44.       this.field_0.showStatus(ResourceLib.GetRes("Done"));
  45.       if (this.m_tvTheTree.isVisible()) {
  46.          this.m_tvTheTree.requestFocus();
  47.          this.m_tvTheTree.repaint();
  48.       }
  49.  
  50.       this.m_tvTheTree.setSelectionToTop();
  51.       this.m_tvTheTree.repaint();
  52.    }
  53.  
  54.    public SiteMapParserToContents(Applet var1, Image[] var2, BsscHelpRedirector var3) {
  55.       this.field_0 = var1;
  56.       this.images = var2;
  57.       this.m_ImageCache = new ImageCache(var1);
  58.       this.parent_list.setSize(1);
  59.       this.parent_list.setElementAt(this.root_tree, 0);
  60.       this.m_rd = var3;
  61.    }
  62.  
  63.    public void object_start() {
  64.       this.in_global = false;
  65.    }
  66.  
  67.    public void throwMessage(String var1) {
  68.       this.field_0.showStatus(var1);
  69.    }
  70.  
  71.    public void indent(int var1) {
  72.       if (var1 == 1) {
  73.          ++this.real_ind;
  74.          if (this.done_a_node) {
  75.             ++this.ind;
  76.          }
  77.       } else if (var1 == -1) {
  78.          this.real_ind += -1;
  79.          this.ind = this.real_ind;
  80.       }
  81.  
  82.       this.done_a_node = false;
  83.    }
  84.  
  85.    public TreeView getTree() {
  86.       if (this.m_tvTheTree == null) {
  87.          this.m_tvTheTree = new TreeView(new ImageSet(this.images), this.root_tree);
  88.       }
  89.  
  90.       this.m_tvTheTree.setApplet(this.field_0);
  91.       this.m_tvTheTree.setBackground(Color.white);
  92.       return this.m_tvTheTree;
  93.    }
  94.  
  95.    public void RemoveEmptyBooks(TreeViewNode var1) {
  96.       if (var1 != null) {
  97.          if (((SiblingChildTree)var1).getChild() != null) {
  98.          }
  99.  
  100.          this.RemoveEmptyBooks((TreeViewNode)((SiblingChildTree)var1).getChild());
  101.          if (((SiblingChildTree)var1).getSibling() != null) {
  102.          }
  103.  
  104.          this.RemoveEmptyBooks((TreeViewNode)((SiblingChildTree)var1).getSibling());
  105.          if (var1 instanceof ContentsTree && ((ContentsTree)var1).local == null && ((SiblingChildTree)var1).getChild() == null) {
  106.             ((SiblingChildTree)var1).pruneThisSubtree();
  107.          }
  108.  
  109.       }
  110.    }
  111.  
  112.    public void start() {
  113.       if (this.m_tvTheTree != null) {
  114.          this.m_tvTheTree.setFilled(false);
  115.          this.m_tvTheTree.requestFocus();
  116.       }
  117.  
  118.       if (this.m_tvTheTree == null) {
  119.          this.m_tvTheTree = new TreeView(new ImageSet(this.images), this.root_tree);
  120.       }
  121.  
  122.       this.m_tvTheTree.SetWaitCursor();
  123.    }
  124.  
  125.    public boolean matchType(String var1) {
  126.       return var1 != null && var1.toUpperCase().endsWith(".HHC");
  127.    }
  128.  
  129.    public void putImage(String var1, long var2, Object var4) {
  130.       try {
  131.          this.m_ImageCache.putImage(var1, var2, var4);
  132.       } catch (Exception var6) {
  133.          ((Throwable)var6).printStackTrace();
  134.       }
  135.    }
  136.  
  137.    public void object_end() {
  138.       if (this.ind < 1 && this.m_tvTheTree.isVisible()) {
  139.          this.m_tvTheTree.repaint();
  140.       }
  141.  
  142.       ContentsTree var1 = new ContentsTree(this.field_0, this.images, this.name, this.local, this.url, this.frame_name == null ? this.default_frame_name : this.frame_name, this.use_folder_images, this.new_topic, this.imageSource, this.imageSourceOpen, this.m_ImageCache, this.m_rd);
  143.       this.parent_list.setSize(this.ind + 2);
  144.       TreeViewNode var2 = (TreeViewNode)this.parent_list.elementAt(this.ind);
  145.       ((SiblingChildTree)var2).addChild(var1);
  146.       this.parent_list.setElementAt(var1, this.ind + 1);
  147.       this.done_a_node = true;
  148.       if (this.m_nItems % 3 == 0 && this.m_nItems % 4 == 0) {
  149.          this.field_0.showStatus(ResourceLib.GetRes("LoadingTOCItem") + " [" + this.m_nItems + "]");
  150.       }
  151.  
  152.       ++this.m_nItems;
  153.       this.name = null;
  154.       this.local = null;
  155.       this.frame_name = null;
  156.       this.new_topic = false;
  157.       this.imageSource = null;
  158.       this.imageSourceOpen = null;
  159.    }
  160.  
  161.    public void param(String var1, String var2) {
  162.       if (this.in_global) {
  163.          if (var1.equalsIgnoreCase("ImageType")) {
  164.             this.use_folder_images = var2.equalsIgnoreCase("Folder");
  165.             return;
  166.          }
  167.  
  168.          if (var1.equalsIgnoreCase("FrameName")) {
  169.             this.default_frame_name = var2;
  170.             return;
  171.          }
  172.       } else {
  173.          switch (Character.toUpperCase(var1.charAt(0))) {
  174.             case 'F':
  175.                if (var1.equalsIgnoreCase("FrameName")) {
  176.                   this.frame_name = var2;
  177.                   return;
  178.                }
  179.                break;
  180.             case 'I':
  181.                if (var1.equalsIgnoreCase("ImageSource")) {
  182.                   this.imageSource = var2;
  183.                   return;
  184.                }
  185.  
  186.                if (var1.equalsIgnoreCase("ImageSourceOpen")) {
  187.                   this.imageSourceOpen = var2;
  188.                   return;
  189.                }
  190.                break;
  191.             case 'L':
  192.                if (var1.equalsIgnoreCase("Local")) {
  193.                   this.local = var2;
  194.                   return;
  195.                }
  196.                break;
  197.             case 'N':
  198.                if (var1.equalsIgnoreCase("Name")) {
  199.                   this.name = this.fixSpecialCharacters(var2);
  200.                   return;
  201.                }
  202.  
  203.                if (var1.equalsIgnoreCase("New")) {
  204.                   this.new_topic = var2.equalsIgnoreCase("1");
  205.                   return;
  206.                }
  207.                break;
  208.             case 'U':
  209.                if (var1.equalsIgnoreCase("URL")) {
  210.                   this.url = var2;
  211.                   return;
  212.                }
  213.          }
  214.       }
  215.  
  216.    }
  217.  
  218.    String fixSpecialCharacters(String var1) {
  219.       if (var1 == null) {
  220.          return null;
  221.       } else {
  222.          int var2 = var1.indexOf(38);
  223.          if (var2 < 0) {
  224.             return var1;
  225.          } else {
  226.             String var3 = "";
  227.  
  228.             while(var2 > -1 && var2 < var1.length() - 2) {
  229.                var3 = var3 + var1.substring(0, var2);
  230.                String var4 = var1.substring(var2);
  231.                int var5 = var4.indexOf(59);
  232.                if (var5 < 0) {
  233.                   var3 = var3 + var4;
  234.                   break;
  235.                }
  236.  
  237.                if (var5 < var4.length() - 1) {
  238.                   var1 = var4.substring(var5 + 1);
  239.                } else {
  240.                   var1 = "";
  241.                }
  242.  
  243.                var4 = var4.substring(1, var5);
  244.                switch (Character.toUpperCase(var4.charAt(0))) {
  245.                   case 'A':
  246.                      if (var4.equalsIgnoreCase("amp")) {
  247.                         var4 = "&";
  248.                      }
  249.                      break;
  250.                   case 'C':
  251.                      if (var4.equalsIgnoreCase("copy")) {
  252.                         var4 = "(c)";
  253.                      }
  254.                      break;
  255.                   case 'G':
  256.                      if (var4.equalsIgnoreCase("gt")) {
  257.                         var4 = ">";
  258.                      }
  259.                      break;
  260.                   case 'L':
  261.                      if (var4.equalsIgnoreCase("lt")) {
  262.                         var4 = "<";
  263.                      }
  264.                      break;
  265.                   case 'N':
  266.                      if (var4.equalsIgnoreCase("nbsp")) {
  267.                         var4 = " ";
  268.                      }
  269.                      break;
  270.                   case 'Q':
  271.                      if (var4.equalsIgnoreCase("quot")) {
  272.                         var4 = "\"";
  273.                      }
  274.                      break;
  275.                   case 'R':
  276.                      if (var4.equalsIgnoreCase("reg")) {
  277.                         var4 = "(R)";
  278.                      }
  279.                }
  280.  
  281.                var3 = var3 + var4;
  282.                var2 = var1.indexOf(38);
  283.                if (var2 < 0) {
  284.                   var3 = var3 + var1;
  285.                }
  286.             }
  287.  
  288.             return var3;
  289.          }
  290.       }
  291.    }
  292. }
  293.