package com.sun.sysid.panels;

import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import com.sun.wizards.panels.*;
import com.sun.wizards.core.*;
import com.sun.wizards.awt.*;
import com.sun.sysid.core.*;

public class ConfirmPanel extends WizardLeaf implements ActionListener, Runnable
{
 
  Panel waitPanel = null;
  Pinwheel pw = null;
  Panel spinnerPanel = null;

  static String confirmString;
  String hostName = null;
  String timeZone = null;
  String subNetMask = null;
  String ipAddress = null;
  String ifName = null;
  String nameService = null;
  String domainName = null;
  //NIS ANS NIS+
  String nameServerName = null;
  String nameServerAddr = null;
  //DNS
  String[] nameServers = new String[3];
  String[] srchList = new String[6];

  Boolean isNetworked = new Boolean(true);
  Boolean isDHCP = new Boolean(false);
  Boolean subNet = new Boolean(true);
  Boolean findAServer = new Boolean(true);
  Boolean eStarOn = new Boolean(true);
  Boolean usePM = new Boolean(true);
  Boolean askAtReboot = new Boolean(true);
  Boolean needsProxy = new Boolean(true);
  boolean success = false;
  transient boolean confirmed = false;
  String endLine = new String("");
    boolean finished;
    private boolean warp = false;
  Panel navPanel;
  
  InsetsPanel summaryPanel = null;
  int lineNum = 0;
  String sequence;
  Button confirmButton = null;
  TextArea summary = null;

  PanelServices psvc = new PanelServices();

  /* Error Codes from sysidput */
   /* sysidput nsconfig failed*/
  private static final int SYSIDPUT_FAILED = -2;
  /* No sysidcfg */  
  private static final int NO_SYSIDFILE = -25;
  /* No network interface */
  private static final int NO_NETIF =     -26;
  /* No hostname */
  private static final int NO_HOSTNAME =  -27;
  /* No IP address */
  private static final int NO_IPADDR =    -28;
  /* No Netmask */
  private static final int NO_NETMASK =   -29;
  /* Missing some net info */
  private static final int NO_ALLINFO =   -30;
  /* Locale info Missing */
  private static final int NO_LOCALE =    -31;
  /* Missing termtype */
  private static final int NO_TERMTYPE =  -32;
  /* Name service setup error */
  private static final int NS_ERROR =     -33;

  public ConfirmPanel()
    {
    }
  
  public ConfirmPanel(WizardState wizardState, String name)
    {
      super(wizardState, name);
    }
  
  public ConfirmPanel(WizardState wizardState)
    {
      super(wizardState, "Confirm Information");
      wizardState.addChildObject("sysIDServerObj",
				 new SysIDServerObject());
    }
  
  public ConfirmPanel(String name, Route route, 
		      WizardTreeManager wizardManager)
    {
      super(name, route, wizardManager);
    }
  
  
  public void printConfigInfo()
    {
      WizardTreeManager wizardManager = getTreeManager();
      endLine = System.getProperty("line.separator");
      
      
      isNetworked = 
	(Boolean) wizardManager.callServerObjectMethod(getRoute(),
				"getData",
				new String[] { "java.lang.String.class" },
				new Object[] {"isNetworked"});
      needsProxy =
	  (Boolean) wizardManager.callServerObjectMethod(getRoute(),
				"getData",
				new String[] { "java.lang.String.class" },
				new Object[] {"needsProxy"});
				   
      if (isNetworked.booleanValue()) {
	printNetworkInfo();
	printNsInfo();
	if (wizardManager.hasGUI()) {
		printProxyInfo();
	}
      } else {
	hostName = 
	  (String) wizardManager.callServerObjectMethod(getRoute(),
				"getData",
				new String[] { "java.lang.String.class" },
				new Object[] { "hostName"});
	if (!hostName.equals(null)){
	  summary.append(MsgCat.getString("com.sun.sysid.Sysid", 
					"Host Name:") 
		       + " " + hostName + endLine);
	}
      }
      printOtherInfo();

    }
  
  
  public void createUI()
    {
      WizardTreeManager wizardManager = getTreeManager();
      navPanel = wizardManager.getNavigationPanel();
      super.createUI();

      /*
       * Set the header text.
       */
      HeaderPanel headerPanel = getHeaderPanel();

      String heading = MsgCat.getString("com.sun.sysid.Sysid", 
					  "Confirm Information");

      if(headerPanel != null) {
        headerPanel.setText(heading);
      }

    }
  
  public void beginDisplay()
    {
      WizardTreeManager wizardManager = getTreeManager();
      int h, w;
      super.beginDisplay();
      if (summaryPanel != null)
	{
	  remove(summaryPanel);
	  summaryPanel = null;
	}
      if (navPanel != null)
      {
	 navPanel.add(confirmButton =
		      new Button(MsgCat.getString("com.sun.sysid.Sysid", 
						  "Confirm")),
		      "Navigation");
	 confirmButton.addActionListener(this);
      }
      summaryPanel = new InsetsPanel(new BorderLayout());
      summaryPanel.setInsets(new Insets(0,0,10,10));
      Dimension d = summaryPanel.getSize();
      h = d.height;
      w = d.width;
      summary = new TextArea(h, w);
      summary.setEditable(false);
      summaryPanel.add(new FlowLabel("<bold>" + 
				     MsgCat.getString("com.sun.sysid.Sysid", 
					"confirmString") + 
				        "</bold>"), "North");
      //++lineNum;
      printConfigInfo();
      
      summaryPanel.add(summary, "Center");
      add(summaryPanel, "Center");
    }
  

  public void consoleInteraction() 
    {
      if( warp ) {
	warp = false;
	wizardManager.warpToLeaf(wizardManager.getFirstComponent());
	return;
      }
      if (success)
	success = false;
      while (!success){  
	TTYDisplay.showNewline();
	TTYDisplay.showText( MsgCat.getString("com.sun.sysid.Sysid", 
					      "cli_confirmDesc") );
	TTYDisplay.showNewline();
         
	Vector tableData = new Vector();
	for( StringTokenizer lines = new StringTokenizer(summary.getText(), "\n");
	     lines.hasMoreTokens(); 
	     ) {
	  String line = lines.nextToken();
	    
	  Vector rowData = new Vector();
	  int pos = line.indexOf(":");
	    
	  if( pos != -1 ) {
	    rowData.addElement( line.substring(0, pos + 1).trim() );
	    rowData.addElement( line.substring(pos + 1).trim() );
	  } else {
	    rowData.addElement( "" );
	    rowData.addElement( line.trim() );
	  }
	    
	  tableData.addElement( rowData );
	}
         
	TTYDisplay.displayTable( tableData );
	TTYDisplay.showNewline();
	 
	boolean answer = false;
	 
	String promptString = MsgCat.getString("com.sun.sysid.Sysid", 
					       "cli_confirmPrompt");
	String helpString = "";
	 
	String yval = MsgCat.getString("com.sun.sysid.Sysid", "y");
	String nval = MsgCat.getString("com.sun.sysid.Sysid", "n");
	 
	String result = 
	  TTYDisplay.queryValue(promptString, TTYDisplay.NO_DEFAULT, 
				new String[] { yval, nval }, 
				helpString);
	 
	if(result.equalsIgnoreCase(yval)) {
	  confirmed = true;
	    
	  finished = false;
	  Thread t = new Thread(this);
	  t.start();
	  waitToFinish();
	} else {
	  wizardManager.warpToLeaf(wizardManager.getFirstComponent());
	  return;
	}
      }
      return;	 
    }

  public int getButtonMask() 
    {
      if (! confirmed)
	return (BACK_BUTTON);
      else
	return (0);
    }

  public boolean isDisplayComplete()
    {
       while (!finished ) {
         try { Thread.sleep( 100 ); } catch( InterruptedException ie) {}
       }
       if( navPanel != null ) {
	  navPanel.remove(confirmButton);
       }
      if ( !success)
      {
	 if( !getTreeManager().hasGUI() ) { 
	    warp = true; 
	 }
	 return false;
      }
      return (true);
    }
  public void abortDisplay()
    {
      super.abortDisplay();
      navPanel.remove(confirmButton);
      
    }
  public void actionPerformed(ActionEvent e)
    {
      Boolean retCode = new Boolean(false);
      WizardTreeManager wizardManager = getTreeManager();
      psvc.actionPerformed(e);
      Button theButton = (Button)e.getSource();

      String confString = null;
      confString = MsgCat.getString("com.sun.sysid.Sysid",
				    "Configuring");

      if (theButton == confirmButton) {	
	remove(summaryPanel);
	confirmed = true;
	navPanel.remove(confirmButton);
	wizardManager.displayCorrectButtons();
	//remove(navPanel);
	waitPanel = new Panel (new BorderLayout());
	spinnerPanel = new Panel(new GridBagLayout());
	 
	pw = new Pinwheel(6 , 6);
	spinnerPanel.add(pw);
	waitPanel.add(new FlowLabel("<bold>" + confString + 
				    "</bold>"), 
		      "North");
	waitPanel.add(spinnerPanel, "Center");
	 
	add(waitPanel, "Center");
	validate();
	finished = false;
	Thread t = new Thread(this);
	t.start();

      }
    }

  public void run() {
    Integer retCode = new Integer(0);
    WizardTreeManager wizardManager = getTreeManager();

    // write the sysidcfg file
    Route route =
      getRoute().getChildServerRoute("sysIDServerObj");
    wizardManager.callServerObjectMethod(route.copy(),
					 "writeCfgFile", null, null);
    
    /*
     * Try to confirm the hostname
     */

    

    if (Def.DEBUG)
      System.out.println("running sysidput");

    if (isNetworked.booleanValue()) {
      if (Def.DEBUG)
	System.out.println("isNetworked = true");
      
      retCode = 
	(Integer) wizardManager.callServerObjectMethod(route.copy(),
				"executeCmd",
				new String[] {"java.lang.String.class"},
				new Object[] {"/usr/sbin/sysidput"});
    } else {
      if (Def.DEBUG)
	System.out.println("isNetworked = false");
      retCode = 
	(Integer) wizardManager.callServerObjectMethod(route.copy(),
			"executeCmd",
			new String[] {"java.lang.String.class"},
			new Object[] {"/usr/sbin/sysidput -h " + hostName});
    }
    if ( retCode.intValue() != 0 ) {
      if (Def.DEBUG)
	System.out.println("error found of type " + retCode.toString());
      success =  promptError(retCode.intValue());
	  
    } else {
      if (Def.DEBUG)
	System.out.println("running sysidsys");

      retCode = 
	(Integer) wizardManager.callServerObjectMethod(route.copy(),
				"executeCmd",
				new String[] {"java.lang.String.class"},
				new Object[] {"/usr/sbin/sysidsys"});

      if (Def.DEBUG)
	System.out.println("running sysidkrb5");
      
      retCode = 
	(Integer) wizardManager.callServerObjectMethod(route.copy(),
				"executeCmd",
				new String[] {"java.lang.String.class"},
				new Object[] {"/usr/sbin/sysidkrb5"});
      if (Def.DEBUG)
	System.out.println("running sysidroot");
     
      retCode =
	(Integer) wizardManager.callServerObjectMethod(route.copy(),
				"executeCmd",
				new String[] {"java.lang.String.class"},
				new Object[] {"/usr/sbin/sysidroot"});
      if (Def.DEBUG)
	System.out.println("removing /tmp/root/etc/sysidcfg");
      retCode =
	(Integer) wizardManager.callServerObjectMethod(route.copy(),
			"executeWaitCmd",
			new String[] {"java.lang.String.class"},
			new Object[] {"mv /tmp/root/etc/sysidcfg " +
				      "/tmp/sysidcfg.used"});
      
      // setup the install system with the sysid info
      if (isNetworked.booleanValue()) {
		wizardManager.callServerObjectMethod(route.copy(),
					"setupKiosk", null, null);
		if (needsProxy.booleanValue()) {
		    wizardManager.callServerObjectMethod(route.copy(),
					"writeProxyConfig", null, null);
		}
      }

      if (Def.DEBUG)
	System.out.println("calling copyHosts");
      retCode =
	(Integer) wizardManager.callServerObjectMethod(route.copy(),
				"executeWaitCmd", 
				new String[] {"java.lang.String.class"},
				new Object[] {"/sbin/cleanup_hosts"});

      success = true;
	    
    }	 
    if (wizardManager.hasGUI())
    {
       remove(waitPanel);
    }

    if (success)
      wizardManager.exit(0);
    else {
      add(summaryPanel);
      confirmed = false;
      wizardManager.displayCorrectButtons();
      if (navPanel != null)
      {
	 navPanel.add(confirmButton);
      }
    }
    finished = true;
  }

  public void waitToFinish()
    {
      while (!finished ) {
	try { Thread.sleep( 100 ); } catch( InterruptedException ie) {}
      }
    }

  private void printOtherInfo() 
    {
      WizardTreeManager wizardManager = getTreeManager();

      timeZone = 
	(String) wizardManager.callServerObjectMethod(getRoute(),
			       "getData",
			       new String[] { "java.lang.String.class" },
			       new Object[] { "timeZoneStr"});

      if (timeZone.equals(null)) {
        timeZone = (String) wizardManager.callServerObjectMethod(getRoute(),
			       "getData",
			       new String[] { "java.lang.String.class" },
			       new Object[] { "timeZone"});
      }

      eStarOn = 
	(Boolean) wizardManager.callServerObjectMethod(getRoute(),
				"getData",
				new String[] { "java.lang.String.class" },
				new Object[] {"eStarOn"});
      askAtReboot = 
	(Boolean) wizardManager.callServerObjectMethod(getRoute(),
				"getData",
				new String[] { "java.lang.String.class" },
				new Object[] {"askAtReboot"});
      usePM =
	  (Boolean) wizardManager.callServerObjectMethod(getRoute(),
				  "getData",
				  new String[] { "java.lang.String.class" },
				  new Object[] {"usePM"});

      if (!timeZone.equals(null)) {
	summary.append(MsgCat.getString("com.sun.sysid.Sysid",
                                        "Time Zone:") + " " +
		       timeZone + endLine);
      }

      // Test the availability of EStar support
      // before appending to the confirm.
      if (usePM.booleanValue()) {
	  summary.append(MsgCat.getString("com.sun.sysid.Sysid" ,
				      "Power Management:") + endLine);
	  if (eStarOn.booleanValue()) {
	      summary.append("     " + 
		       MsgCat.getString("com.sun.sysid.Sysid",
                                        "EStarOn") + endLine);
	  } else {
	      summary.append("     " +
		       MsgCat.getString("com.sun.sysid.Sysid",
					"EStarOff") + endLine);
	 }
  
	  if (askAtReboot.booleanValue()) {
	      summary.append("     " +
		       MsgCat.getString("com.sun.sysid.Sysid" ,
					"ask2") + endLine);
	  } else {
	      summary.append("     " +
		       MsgCat.getString("com.sun.sysid.Sysid",
					"dontAsk2") + endLine);
	  } 
      } // Test for PM availability

    }

  private void printNetworkInfo()
    {
      WizardTreeManager wizardManager = getTreeManager();
      isDHCP = 
	(Boolean)  wizardManager.callServerObjectMethod(getRoute(),
				"getData",
				new String[] { "java.lang.String.class" },
				new Object[] { "isDHCP"});
      Boolean enableIpv6 = 
	(Boolean)  wizardManager.callServerObjectMethod(getRoute(),
				"getData",
				new String[] { "java.lang.String.class" },
				new Object[] { "enableIpv6"});
      if (!isDHCP.booleanValue()) {
	if (isNetworked.booleanValue()) {
	  hostName = 
	    (String) wizardManager.callServerObjectMethod(getRoute(),
				   "getData",
				   new String[] { "java.lang.String.class" },
				   new Object[] { "hostName"});
	  if (!hostName.equals(null)){
	    summary.append(MsgCat.getString("com.sun.sysid.Sysid", 
					    "Host Name:") 
			   + " " + hostName + endLine);
	  }
	  ipAddress = 
	    (String) wizardManager.callServerObjectMethod(getRoute(),
				   "getData",
				   new String[] { "java.lang.String.class" },
				   new Object[] { "ipAddress"});
	
	  if (!ipAddress.equals(null)) {
	    summary.append(MsgCat.getString("com.sun.sysid.Sysid",
					  "promptString")
			 + " " + ipAddress + endLine);
	  }
	subNet = 
           (Boolean) wizardManager.callServerObjectMethod(getRoute(),
				"getData",
			        new String[] { "java.lang.String.class" },
			        new Object[] {"subNet"});
	subNetMask = 
           (String) wizardManager.callServerObjectMethod(getRoute(),
                               "getData",
			       new String[] { "java.lang.String.class" },
			       new Object[] { "subNetMask"});
	if (subNet.booleanValue()) {
           summary.append(MsgCat.getString("com.sun.sysid.Sysid",
                                           "System part of a subnet:") + " " +
                          MsgCat.getString("com.sun.sysid.Sysid", "Yes") +
			  endLine);
           if (! subNetMask.equals(""))
	   {
	      summary.append(MsgCat.getString("com.sun.sysid.Sysid",
					      "Netmask:") + " " + subNetMask +
			     endLine);
	   }
	} else {
           summary.append(MsgCat.getString("com.sun.sysid.Sysid"
                                           ,
                                           "System part of a subnet:") + " " +
                          MsgCat.getString("com.sun.sysid.Sysid", "No") + 
                          endLine);
	}
	
	  ifName = 
	    (String) wizardManager.callServerObjectMethod(getRoute(),
				   "getData",
				    new String[] { "java.lang.String.class" },
				    new Object[] { "ifName"});
	if (enableIpv6.booleanValue())
	  summary.append(MsgCat.getString("com.sun.sysid.Sysid", 
					  "ipvPrompt") + 
			 " " + 
			 MsgCat.getString("com.sun.sysid.Sysid", "Yes") + 
			 endLine);
	else
	  summary.append(MsgCat.getString("com.sun.sysid.Sysid", 
					  "ipvPrompt") + 
			 " " + 
			 MsgCat.getString("com.sun.sysid.Sysid", "No") + 
			 endLine);
	}
      } else {
	summary.append(
	   MsgCat.getString("com.sun.sysid.Sysid", "MSG_USE_DHCP") + " " +  
	   MsgCat.getString("com.sun.sysid.Sysid", "Yes") + 
	   endLine);
      }
    }

    
    
    
  private void printProxyInfo()
  {
  	WizardTreeManager wizardManager = getTreeManager();

	String showHost =
		(String)wizardManager.callServerObjectMethod(getRoute(),
			            "getData",
				    new String[] { "java.lang.String.class" },
				    new Object[] { "proxyServer"});
							
	String showPort =
		(String)wizardManager.callServerObjectMethod(getRoute(),
				   "getData",
				   new String[] { "java.lang.String.class" },
				   new Object[] { "proxyPort"});
							
	// Print out heading...
	summary.append(MsgCat.getString("com.sun.sysid.Sysid",
					"proxyConfirmHead") + endLine);
	if (!needsProxy.booleanValue()) {
		summary.append("     " +
		               MsgCat.getString("com.sun.sysid.Sysid",
					   "useDirect") + endLine);
	} else {
		// Here means we need to use a proxy
		summary.append("     " +
		               MsgCat.getString("com.sun.sysid.Sysid",
					   "proxyHost") + " " + 
			       showHost + endLine);
		summary.append("     " +
		               MsgCat.getString("com.sun.sysid.Sysid",
					   "proxyPort") + " " + 
			       showPort + endLine);
		summary.append(endLine);
		
	}
  } // printProxyInfo()
 
  private void printNsInfo() 
    {
      WizardTreeManager wizardManager = getTreeManager();
      //Begin
     
      nameService = 
	(String) wizardManager.callServerObjectMethod(getRoute(),
			       "getData",
			       new String[] { "java.lang.String.class" },
			       new Object[] { "nameService"});
      if (!nameService.equals(null)) {
	String nsString = MsgCat.getString("com.sun.sysid.Sysid",
					   nameService);
	summary.append(MsgCat.getString("com.sun.sysid.Sysid",
					"Name Service:")
		       + " " + nsString + endLine);	
	if (!nameService.equals("NONE")){
	  domainName = 
	    (String) wizardManager.callServerObjectMethod(getRoute(),
				   "getData",
				   new String[] { "java.lang.String.class" },
				   new Object[] { "domainName"});	
	    
	    
	  if (! domainName.equals(null)) {
	    summary.append(MsgCat.getString("com.sun.sysid.Sysid",
					    "Domain Name:") + " " + 
			   domainName + endLine);
	  }
	  if (nameService.startsWith("NIS")) {
	     prtNisInfo();
	  } else if (nameService.equals("DNS")) {
	     prtDnsInfo();
	  }
	}
	summary.append(endLine);
      }
      
    }
   private void prtNisInfo()
    {
      WizardTreeManager wizardManager = getTreeManager();
      nameServerName = 
	(String) wizardManager.callServerObjectMethod(getRoute(),
			       "getData",
			       new String[] { "java.lang.String.class" },
			       new Object[] { "nameServerName"});
      nameServerAddr = 
	(String) wizardManager.callServerObjectMethod(getRoute(),
			       "getData",
			       new String[] { "java.lang.String.class" },
			       new Object[] { "nameServerAddr"});
      Boolean findAServer =
	(Boolean) wizardManager.callServerObjectMethod(getRoute(),
				"getData",
				new String[] { "java.lang.String.class" },
				new Object[] { "findAServer"});
      if (!findAServer.booleanValue()) {
	if (!nameServerName.equals(null)) {
	  summary.append(MsgCat.getString("com.sun.sysid.Sysid",
					  "Server's host name:")
			 + " " + nameServerName + endLine);
	}
	if (!nameServerAddr.equals("")) {
	  summary.append(MsgCat.getString("com.sun.sysid.Sysid",
					  "Server's IP Address:") + " " +
			 nameServerAddr + endLine);
	}
      } else {
	summary.append(MsgCat.getString("com.sun.sysid.Sysid",
					"Name server:") +
		       " " +
		       MsgCat.getString("com.sun.sysid.Sysid", 
					 "Find one") +
		       endLine);
      }
    }

  
  private void prtDnsInfo()
    {
      WizardTreeManager wizardManager = getTreeManager();
      String spaces = new String("");
      String tmp = new String("");

      nameServers = 
	(String[])  wizardManager.callServerObjectMethod(getRoute(),
				  "getData",
				  new String[] { "java.lang.String.class" },
				  new Object[] { "DNSnameServers"});
      srchList = 
	(String[])  wizardManager.callServerObjectMethod(getRoute(),
				  "getData",
				  new String[] { "java.lang.String.class" },
				  new Object[] { "DNSsearchList"});
      
      if (!nameServers[0].equals(null)) {
	tmp = new String(MsgCat.getString("com.sun.sysid.Sysid", 
				      "DNSsvrIPAddr") + endLine);
	summary.append(tmp);
	for (int j=0; j<=tmp.length(); ++j)
	    spaces = spaces + " ";
	for (int i=0; i<nameServers.length; ++i)
	  if (!nameServers[i].equals(""))
	    summary.append(spaces + nameServers[i] + endLine);	  
      }
      spaces = "";
      if (!srchList[0].equals(null)) { 
	tmp = MsgCat.getString("com.sun.sysid.Sysid",
					"dnsSearchDomain") + endLine;
	summary.append(tmp);
	 for (int j=0; j <= tmp.length(); ++j)
	    spaces = spaces + " ";
	for (int i=0; i<srchList.length; ++i) 
	  if (!srchList[i].equals(""))
	      summary.append(spaces + srchList[i] + endLine);	
      }
    }

  private boolean promptError(int errNum)
    {
      boolean retVal = false;
      String errorStr = "";
      switch (errNum) {
	
      case NO_SYSIDFILE :
	 errorStr="No sysidcfg found";
	psvc.createErrorDialog(MsgCat.getString("com.sun.sysid.Sysid",
						"genSysErr"), this);
	retVal = false;
	break;/* No sysidcfg */
      case NO_NETIF :
	errorStr="No network interface found";
	psvc.createErrorDialog(MsgCat.getString("com.sun.sysid.Sysid",
						"notNetIfErr"), this);
	retVal = false;
	break;/* No network interface */
      case NO_HOSTNAME :
	errorStr="No hostname found";
	psvc.createErrorDialog(MsgCat.getString("com.sun.sysid.Sysid",
						"noHostNameErr"), this);
	retVal = false;
	break; /* no hostname */
      case NO_IPADDR :
	errorStr="No ip address found";
	psvc.createErrorDialog(MsgCat.getString("com.sun.sysid.Sysid",
						"noIpAddrErr"), this);
	retVal = false;
	break; /* No IP address */
      case NO_NETMASK :   
	errorStr="No netmask found";
	psvc.createErrorDialog(MsgCat.getString("com.sun.sysid.Sysid",
						"noNetMaskErr"), this);
	retVal = false;
	break;/* No Netmask */
      case NO_ALLINFO :
	errorStr="Missing network information";
	psvc.createErrorDialog(MsgCat.getString("com.sun.sysid.Sysid",
						"missNetInfoErr"), this);
	retVal = false;
	break;/* Missing some net info */
      case NO_LOCALE :    
	errorStr="No locale found";
	errorStr+="\nLocale info missing from sysidcfg";
	retVal = true;
	break; /* Locale info Missing */
      case NO_TERMTYPE :
        errorStr="No termtype found";
	errorStr+="\nTermtype info missing from sysidcfg";
	retVal = true;
	break;/* Missing termtype */
      case NS_ERROR :
	errorStr="Name server error";
	 	  
     
	psvc.createErrorDialog(MsgCat.getString("com.sun.sysid.Sysid", 
						"inValidNameServer"), this);
	retVal = false;
	break; /* name service error */
      case SYSIDPUT_FAILED :
	errorStr="ns->configure failed";
	psvc.createErrorDialog(MsgCat.getString("com.sun.sysid.Sysid",
						"genSysErr"), this);
	retVal = false;
	break;
      default:
	errorStr="General error, see /var/sadm/system/logs/sysidtool.log";
	psvc.createErrorDialog(MsgCat.getString("com.sun.sysid.Sysid",
						"genSysErr"), this);
	retVal = false;
	break;
      }
      if( getTreeManager().hasGUI() ) {
	 System.err.println(errorStr);
      } else if( Def.DEBUG ) {
	 System.err.println(errorStr);
      }
     return retVal;
    }
  
  public void addRuntimeResources(Vector resourceVector)
    {
      super.addRuntimeResources(resourceVector);
      resourceVector.addElement(new String[] {null, 
			"com.sun.sysid.panels.ConfirmPanel"});
      resourceVector.addElement(new String[] {null, 
			"com.sun.sysid.SysidResources"});
      resourceVector.addElement(new String[] {null, 
			"com.sun.sysid.core.PanelServices"});
      resourceVector.addElement(new String[] {null,
			"com.sun.sysid.core.SysIDServerObject"});
      resourceVector.addElement(new String[] {null, 
			"com.sun.wizards.awt.InsetsPanel"});
      resourceVector.addElement(new String[] {null, 
			"com.sun.wizards.awt.FullWidthPanel"});
      resourceVector.addElement(new String[] {null, 
			"com.sun.wizards.awt.FlowLabel"});
      resourceVector.addElement(new String[] {null, 
			"com.sun.wizards.awt.VerticalLayout"});
      resourceVector.addElement(new String[] {null,
                        "com.sun.wizards.awt.Separator"});
    }
}
