/*
//  FileName: sketchpad.java
// 
//  Al Geist         Mar 13, 1997  modified to become notebook sketchpad 
//  Vijay Konkimalla Dec 7, 1995 original whiteboard design
//   
//
//  Objective: 
//
//  $Author:$
//  $Log:$
//  $Id:$
*/



import  java.awt.*;
import  java.applet.*;
import  java.lang.*;
import  java.util.*;
import  java.io.*;
import  java.net.*;


import  wb.*;

// Let us pack every thing into an Applet which can run stand alone
// For Now....
public class sketchpad extends Applet
{

    WBFrame window = null;
    public sketchpad()
    {
        window = new WBFrame( true );
    }

    public sketchpad(String args[])
    {
        if ( args.length == 0 ) {
            WBFrame window = new WBFrame( true );
        } else {
            WBFrame window = new WBFrame( args, args.length/2, true );
        }
    }

    public void init()           // run if applet
    {
        if ( window != null ) {
            window.show();
        }

	/* 
	 * Pass Configuration Parameters To Global Variable 
	 * Object For Access By The wb Library
	 */
	    Global.setServer   ( getParameter("Server")   );
	    Global.setEngine   ( getParameter("Engine")   );
	    Global.setNotebook ( getParameter("Notebook") );
	    Global.setPage     ( getParameter("Page") );

System.out.println("");
System.out.println("Sketchpad's Electronic Notebook Configuration:");
System.out.println("    Server = "   + Global.server);
System.out.println("    Engine = "   + Global.engine);
System.out.println("    Notebook = " + Global.notebook);
System.out.println("    Page = "     + Global.page);
System.out.println("");




	/* 
	 * Pass Handle Of This Applet To Global Variable 
	 * Object For Access By The wb Library
	 */
	    
	    Global.setAppletContext ( getAppletContext() );
//	 try{
//	    URL myhome = new URL("HTTP", "www.epm.ornl.gov", "/~elmore");
//	    getAppletContext().showDocument(myhome, "_top");
//	 }catch ( MalformedURLException e ) {};


    }

    public static void main(String args[])  //run if stand-alone
    {
        int nousers = (args.length-2)/2;
        for ( int index = 0; index < nousers; index++ ) 
                System.out.println( "localuser: " + args[0] 
                        + " localhost: " + args[1] 
                        + " remote user: " +  args[2*index+2]
                        + " remote host: " + args[2*index+3] );
        if ( args.length < 4 ) {
            System.out.println("Insufficient Users, going editor mode");
            WBFrame window = new WBFrame( true );
            window.show();
        } else {
            WBFrame window = new WBFrame( args, (args.length-2)/2, true );
            window.show();
        }

    }
   
    public boolean handleEvent( Event evt )
    {
        if ( evt.id == Event.WINDOW_DESTROY ){
            try{
                System.exit(0);
            }catch ( Exception excep ) {
            }finally {
                stop();
            }
            return true;
        }      
        return false;
    }
}


/*
 * End of File: sketchpad.java
 */
