home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.BorderLayout;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.net.URL;
- import java.util.StringTokenizer;
-
- public class Sitemapper extends Applet {
- String window_name;
- String url_path;
- web_structure_builder wsb;
- tree_grid_builder tgb;
- button_panel view_buttons;
- nav_canvas main_canvas;
- outline_list main_list_box;
- check_box_panel user_level_panel;
- search_panel search_area;
- static String seperator_string = "*";
-
- public void load_site_info(String contents) {
- this.window_name = "netobjects_main_power";
-
- try {
- URL url = new URL(((Applet)this).getDocumentBase().toString());
- this.url_path = url.getProtocol() + "://" + url.getHost();
- if (url.getPort() != -1) {
- String var10001 = this.url_path;
- this.url_path = var10001 + ":" + url.getPort();
- }
-
- String var6 = this.url_path;
- this.url_path = var6 + url.getFile();
- this.url_path = this.url_path.substring(0, this.url_path.indexOf("Sitemapper.html"));
- } catch (Exception var4) {
- }
-
- StringTokenizer tokenizer = new StringTokenizer(contents, seperator_string);
- if (tokenizer.countTokens() > 0) {
- this.wsb = new web_structure_builder(tokenizer);
- this.tgb = new tree_grid_builder(this.wsb.web_tree, this.wsb.max_level);
- } else {
- System.out.println("No text file to read");
- }
- }
-
- void show_url(String target_url) {
- try {
- ((Applet)this).getAppletContext().showDocument(new URL(this.url_path + target_url), this.window_name);
- } catch (Exception var4) {
- System.out.println("error showing url");
- }
- }
-
- void remove_current_components(int view) {
- if (view == 0) {
- ((Container)this).remove(this.main_canvas);
- ((Container)this).remove(this.user_level_panel);
- } else if (view == 1) {
- ((Container)this).remove(this.main_list_box);
- ((Container)this).remove(this.user_level_panel);
- } else if (view == 2) {
- ((Container)this).remove(this.search_area);
- }
-
- }
-
- void setup_components() {
- ((Container)this).setLayout(new BorderLayout(10, 10));
- this.view_buttons = new button_panel(this);
- ((Container)this).add("North", this.view_buttons);
- this.user_level_panel = new check_box_panel(this);
- ((Container)this).add("South", this.user_level_panel);
- this.main_list_box = new outline_list(this.wsb.web_list, this);
- this.search_area = new search_panel(this.wsb.web_list, this);
- this.main_canvas = new nav_canvas(this.tgb.tree_grid, this.wsb.max_level, this.tgb.my_max_width, this);
- }
-
- public void init() {
- super.init();
- ((Component)this).setBackground(Color.white);
- this.load_site_info(((Applet)this).getParameter("source_file"));
- this.setup_components();
- this.display_view(this.view_buttons.view);
- }
-
- void display_view(int view) {
- if (view == 1) {
- ((Container)this).add("Center", this.main_list_box);
- this.main_list_box.draw_web_list();
- } else if (view == 0) {
- ((Container)this).add("Center", this.main_canvas);
- this.main_canvas.repaint();
- } else if (view == 2) {
- ((Container)this).add("Center", this.search_area);
- }
-
- ((Container)this).validate();
- }
- }
-