package com.sun.solarisinstall.progress.tasks;

import java.io.*;
import java.util.*;
import com.sun.wizards.core.*;
import com.sun.install.*;
import com.sun.install.products.*;
import com.sun.solarisinstall.*;
import com.sun.solarisinstall.panels.*;
import com.sun.solarisinstall.progress.*;

public class ProgressInitTask extends Task implements Serializable
{
  protected transient WizardState state = null;
  protected boolean done = false;

  /*
   * This constructor is used by the builder.
   */
  public ProgressInitTask(WizardState state)
  {
    this.state = state;
  }

  /**
   * Perform action
   */
  public void perform()
  {    
    state = getSequence().getState();    
    WizardState rootState = state.getRootWizardState();
    String productName = (String) rootState.getData(ProfileConstants.osName);

    if (Def.DEBUG) System.out.println("Setting Product Name to " + productName);
    state.setData(InstallConstants.productName, productName);
    
    String init=
	MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
			  SolarisInstallResources.MSG_INT);
    Msg status = new Msg(productName + " [ " + init + " ] ");
    state.setProgressLabel("install", status);

    rootState.setProgressLabel(
	"install", 
	new Msg("com.sun.install.Install", InstallResources.MSG_TOTAL));
  }

  public WizardState getWizardState() 
  {
    return(state);
  }

  /**
   * Add the runtime class requirements to the specified vector.
   */
  public void addRuntimeResources(Vector resourceVector)
  {
    resourceVector.addElement(new String[] {null, 
	"com.sun.solarisinstall.progress.tasks.ProgressInitTask"});
    resourceVector.addElement(new String[] {null, 
	"com.sun.wizards.builder.ResourceWriter"});
    resourceVector.addElement(new String[] {null, 
	"com.sun.solarisinstall.panels.FileAgent"});
    resourceVector.addElement(new String[] {null, 
	"com.sun.solarisinstall.panels.FileAgentException"});
    resourceVector.addElement(new String[] {null, 
	"com.sun.wizards.core.Msg"});
    resourceVector.addElement(new String[] {null, 
	"com.sun.install.products.InstallConstants"});
  }
}
