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