home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2003 March / DPPCPRO0303.ISO / Netfusion / data1.cab / Components / SiteMapper / Sitemapper.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-12-10  |  4.2 KB  |  101 lines

  1. import java.applet.Applet;
  2. import java.awt.BorderLayout;
  3. import java.awt.Color;
  4. import java.awt.Component;
  5. import java.awt.Container;
  6. import java.net.URL;
  7. import java.util.StringTokenizer;
  8.  
  9. public class Sitemapper extends Applet {
  10.    String window_name;
  11.    String url_path;
  12.    web_structure_builder wsb;
  13.    tree_grid_builder tgb;
  14.    button_panel view_buttons;
  15.    nav_canvas main_canvas;
  16.    outline_list main_list_box;
  17.    check_box_panel user_level_panel;
  18.    search_panel search_area;
  19.    static String seperator_string = "*";
  20.  
  21.    public void load_site_info(String contents) {
  22.       this.window_name = "netobjects_main_power";
  23.  
  24.       try {
  25.          URL url = new URL(((Applet)this).getDocumentBase().toString());
  26.          this.url_path = url.getProtocol() + "://" + url.getHost();
  27.          if (url.getPort() != -1) {
  28.             String var10001 = this.url_path;
  29.             this.url_path = var10001 + ":" + url.getPort();
  30.          }
  31.  
  32.          String var6 = this.url_path;
  33.          this.url_path = var6 + url.getFile();
  34.          this.url_path = this.url_path.substring(0, this.url_path.indexOf("Sitemapper.html"));
  35.       } catch (Exception var4) {
  36.       }
  37.  
  38.       StringTokenizer tokenizer = new StringTokenizer(contents, seperator_string);
  39.       if (tokenizer.countTokens() > 0) {
  40.          this.wsb = new web_structure_builder(tokenizer);
  41.          this.tgb = new tree_grid_builder(this.wsb.web_tree, this.wsb.max_level);
  42.       } else {
  43.          System.out.println("No text file to read");
  44.       }
  45.    }
  46.  
  47.    void show_url(String target_url) {
  48.       try {
  49.          ((Applet)this).getAppletContext().showDocument(new URL(this.url_path + target_url), this.window_name);
  50.       } catch (Exception var4) {
  51.          System.out.println("error showing url");
  52.       }
  53.    }
  54.  
  55.    void remove_current_components(int view) {
  56.       if (view == 0) {
  57.          ((Container)this).remove(this.main_canvas);
  58.          ((Container)this).remove(this.user_level_panel);
  59.       } else if (view == 1) {
  60.          ((Container)this).remove(this.main_list_box);
  61.          ((Container)this).remove(this.user_level_panel);
  62.       } else if (view == 2) {
  63.          ((Container)this).remove(this.search_area);
  64.       }
  65.  
  66.    }
  67.  
  68.    void setup_components() {
  69.       ((Container)this).setLayout(new BorderLayout(10, 10));
  70.       this.view_buttons = new button_panel(this);
  71.       ((Container)this).add("North", this.view_buttons);
  72.       this.user_level_panel = new check_box_panel(this);
  73.       ((Container)this).add("South", this.user_level_panel);
  74.       this.main_list_box = new outline_list(this.wsb.web_list, this);
  75.       this.search_area = new search_panel(this.wsb.web_list, this);
  76.       this.main_canvas = new nav_canvas(this.tgb.tree_grid, this.wsb.max_level, this.tgb.my_max_width, this);
  77.    }
  78.  
  79.    public void init() {
  80.       super.init();
  81.       ((Component)this).setBackground(Color.white);
  82.       this.load_site_info(((Applet)this).getParameter("source_file"));
  83.       this.setup_components();
  84.       this.display_view(this.view_buttons.view);
  85.    }
  86.  
  87.    void display_view(int view) {
  88.       if (view == 1) {
  89.          ((Container)this).add("Center", this.main_list_box);
  90.          this.main_list_box.draw_web_list();
  91.       } else if (view == 0) {
  92.          ((Container)this).add("Center", this.main_canvas);
  93.          this.main_canvas.repaint();
  94.       } else if (view == 2) {
  95.          ((Container)this).add("Center", this.search_area);
  96.       }
  97.  
  98.       ((Container)this).validate();
  99.    }
  100. }
  101.