package com.sun.launcher.panels;

import java.awt.*;
import java.util.*;
import com.sun.wizards.panels.*;
import com.sun.wizards.core.*;
import com.sun.wizards.awt.*;
import com.sun.launcher.*;

public class RebootPanel extends com.sun.wizards.panels.TextImagePanel
{
      private boolean visited = false;

  public RebootPanel()
	{
	}



   public RebootPanel(WizardState wizardState, String name)
    {
      super(wizardState, name);
    }
    public RebootPanel(WizardState wizardState)
    {
      super(wizardState, "Ready to Reboot");
    }
    public RebootPanel(String name, Route route, WizardTreeManager wizardManager) 
   {
      super(name, route, wizardManager);
   }

  public void createUI()
    {
      super.createUI();

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

      String heading = MsgCat.getString(
		"com.sun.launcher.Launcher", 
		LauncherResources.MSG_REBOOT);

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

      /*
       * Set contents text.
       */

      add(new FlowLabel(
	 MsgCat.getString("com.sun.launcher.Launcher",
	 LauncherResources.MSG_REBOOT_CONTINUE)), "Center");
    }

      public void consoleInteraction()
      {
	 if (!visited)
	 {
	    TTYDisplay.showNewline();
	    String cliRebootString = MsgCat.getString(
	       "com.sun.launcher.Launcher",
	       LauncherResources.MSG_CLI_REBOOT_CONTINUE);
	    TTYDisplay.queryValue(cliRebootString, "");
	    visited = true;
	 }
      }

    public void beginDisplay()
      {
	WizardTreeManager wizardManager = getTreeManager();
        super.beginDisplay();
	
        /*
         * Change the label of "exit" function button to be "Reboot Now".
         */
	if (wizardManager.hasGUI())
	{
	   wizardManager.setButtonLabel(
	      "exit",
	      MsgCat.getString(
		 "com.sun.launcher.Launcher",
		 LauncherResources.MSG_REBOOT_NOW));
	}
     }

      public int getButtonMask()
      {
          /*
           * This is really the "reboot" button, don't remove it
           */
          return(EXIT_BUTTON);
      }
    
       public void addRuntimeResources(Vector resourceVector)
       {
          super.addRuntimeResources(resourceVector);
          resourceVector.addElement(new String[] 
		{null, "com.sun.launcher.LauncherResources"});
          resourceVector.addElement(new String[] 
		{null, "com.sun.launcher.panels.RebootPanel"});
	}
}
