package com.sun.solarisinstall.panels;

import java.awt.*;
import java.awt.event.*;
import java.util.*;
import com.sun.wizards.core.*;
import com.sun.wizards.awt.*;
import com.sun.solarisinstall.*;

public class DiskTableFrame extends Frame implements ActionListener, 
  FocusListener, DiskTableListener
{
  private DiskTableManager tableManager;
  //commont to the MB and Cyls panels
  private String diskName;
  protected Button okButton = null;
  protected Button applyButton = null;
  protected Button resetButton = null;
  protected Button cancelButton = null;
  protected Button mbButton = null;
  protected Button cylButton = null;

  protected FilteredTextField[] fsnames;

  protected FilteredTextField[] fsnamesCyls;

  protected FilteredTextField[] fssizes;

  protected FilteredTextField[] fssizesCyls;
  protected FilteredTextField[] fsstartCyl;

  protected MinSizeLabel[] minsize;
  protected MinSizeLabel[] minsizeCyls;

  protected Label freeLabel, allocLabel, roundLabel;
  protected Label freeLabelCyls, allocLabelCyls, nextAvailLabelCyl;

  private MessageFrame msgDialog = null;
  private boolean once = false;
 
  private CardLayout cardLayout = new CardLayout();
  private Panel cardPanel = new Panel(cardLayout);

  private int currentMode = DiskTableManager.MB_MODE;


  public DiskTableFrame( DiskTableManager dtm, String name ) 
    {
      super();
      tableManager = dtm;
      diskName = name;
      super.setTitle (MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
			 SolarisInstallResources.MSG_DISK_LOWERCASE) + diskName);
      createUI();
      tableManager.addTableListener( this );
    }

  public void createUI()
    {
      setLayout(new BorderLayout());
      
      Panel buttonPanel = new Panel();
      buttonPanel.setLayout(new GridLayout(1, 4));
      // OK
      okButton =
	new Button(MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				    SolarisInstallResources.MSG_OK_NOSPACE));
      okButton.addActionListener(this);
      // Apply
      applyButton =
	new Button(MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				SolarisInstallResources.MSG_APPLY_LOWERCASE));
      applyButton.addActionListener(this);
      // Reset
      resetButton =
	new Button(MsgCat.getString("com.sun.solarisinstall.SolarisInstall",
				 SolarisInstallResources.MSG_RESET_LOWERCASE));
      resetButton.addActionListener(this);
      // Cancel
      cancelButton =
	new Button(MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				SolarisInstallResources.MSG_CANCEL_LOWERCASE));
      cancelButton.addActionListener(this);
      
      buttonPanel.add(okButton);
      buttonPanel.add(applyButton);
      buttonPanel.add(resetButton);
      buttonPanel.add(cancelButton);
      
      Panel southPanel = new Panel();
      southPanel.setLayout(new BorderLayout());
      southPanel.add("North", new Separator());    
      southPanel.add("South", buttonPanel);
      add("South", southPanel);

      Panel cardHolderPanel = new Panel(new BorderLayout());
      Panel sliceMbPanel = createSliceMbPanel();
      Panel sliceCylPanel = createSliceCylPanel();
      cardPanel.add(sliceMbPanel, "MB");
      cardPanel.add(sliceCylPanel, "Cyls");
      if (!tableManager.isSwapAtFront()) {
	cardLayout.last(cardPanel);
      } else {
	cardLayout.first(cardPanel);
      }
      cardHolderPanel.add("Center", cardPanel);
      mbButton = new Button("MB");
      cylButton = new Button("Cyl");
      
      if (!tableManager.isSwapAtFront()) {
	//No changes allowed. disable the buttons
	mbButton.setEnabled(false);
        cylButton.setEnabled(false);
	currentMode = DiskTableManager.CYL_MODE;
      } else {
	cylButton.setEnabled(true);
	mbButton.setEnabled(false);
	mbButton.addActionListener(this);
	cylButton.addActionListener(this);
	currentMode = DiskTableManager.MB_MODE;
      }
      
      Panel southWest = new Panel(new BorderLayout());
      Panel gbl = new Panel(new GridLayout(1,2));
      gbl.add(mbButton);
      gbl.add(cylButton);
      southWest.add("South", gbl);
      cardHolderPanel.add("South", southWest);

      add("Center", cardHolderPanel);

      //int width = 385;
      //int height = 450;
      //setSize(width, height);
      pack();
      Component parent = tableManager.getDTMParent();
      Point parentLocation = parent.getLocationOnScreen();
      Dimension parentSize = parent.getSize();
      Dimension thisSize = getSize();
      int x = parentLocation.x + (parentSize.width - thisSize.width)/2 - 80;
      int y = parentLocation.y + (parentSize.height - thisSize.height)/2 - 40;
      
      setLocation(x, y); 
      
      setVisible(true);
    }

 private Panel createSliceMbPanel()
    {
      int numSlices = tableManager.getNumSlices(diskName);
      int freeSpace = tableManager.getFreeSpace(diskName);
      int diskSize = tableManager.getDiskSize(diskName);
      int usedSpace = diskSize - freeSpace;
      int roundErr = tableManager.getRoundError(diskName);

      Panel out = new Panel();
      out.setLayout(new BorderLayout(0, 15));
      
      Panel table = new Panel();
      table.setLayout(new ColumnLayout());

      fsnames = new FilteredTextField[numSlices];
      fssizes = new FilteredTextField[numSlices];
      minsize = new MinSizeLabel[numSlices];

      Font font = new Font("Dialog", Font.BOLD, 12);
      Label l = new Label(MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
					   SolarisInstallResources.MSG_SLICE_HEADER));
      l.setFont(font);
      table.add(l);
      for (int i = 0; i < numSlices; i++) {
	if (i == 2) {
	  i++;
	}
	
	Panel row = new Panel();
	row.setLayout(new RowLayout(LAYOUT_ALIGNMENT.CENTER, 20,0));
	
	fsnames[i] = new FilteredTextField(15);
	fsnames[i].addDeniedCharacters(" ");
	fsnames[i].setName(String.valueOf(i));
	
	fssizes[i] = new FilteredTextField("", 5, 100, FilteredTextField.TYPE_NUMERIC);
	fssizes[i].setName(String.valueOf(i));
	
	minsize[i] = new MinSizeLabel("");
	
	fsnames[i].addFocusListener(this);
	fssizes[i].addFocusListener(this);

	if (!tableManager.getSliceName(diskName, i).equals("")) { 
	  fsnames[i].setText(tableManager.getSliceName(diskName, i));
	  
	  int min = tableManager.getSliceMinSize(diskName, i);
	  fssizes[i].setText(String.valueOf(min));

	  if (min == 0) {
	    minsize[i].setAlignment(Label.CENTER);
	    minsize[i].setText("");
	  } else {
	    minsize[i].setAlignment(Label.CENTER);
	    minsize[i].setText(String.valueOf(min) +
			       MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
						SolarisInstallResources.MSG_SINGLESPACE_MB));
	  }
	  fssizes[i].setText(String.valueOf(tableManager.getSliceSize(diskName, i) ));
	  
	  if ( tableManager.isDefaultSwapSlice( diskName, i ) ) {
	    fsnames[i].setEditable(false);
	    fssizes[i].setEditable(false);
	    minsize[i].setAlignment(Label.CENTER);
	    minsize[i].setText("");
	    fsnames[i].removeFocusListener(this);
	    fssizes[i].removeFocusListener(this);
	  }
	}
      
	row.add(new Label(" " + String.valueOf(i), Label.CENTER));
	row.add(fsnames[i]);
	
	row.add(fssizes[i]);
	row.add(minsize[i]);
	table.add(row);
      }

      Panel insetp = new Panel();
      insetp.setLayout(new BorderLayout());
      insetp.add("Center", table);
      out.add("Center", insetp);

      Object[] msgArgs = {diskName, new Integer(diskSize)};
      l = new Label(MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				     SolarisInstallResources.MSG_DISK_IN_MB,
				     msgArgs));
      l.setBackground(Color.blue);
      l.setForeground(Color.white);
      l.setFont(new Font(font.getName(), font.BOLD, 14));
      out.add("North", l);
      
      Panel south = new Panel();
      south.setLayout(new BorderLayout());
    
      Panel southEast = new Panel();
      southEast.setLayout(new FieldLayout(5,0));

      l = new Label(MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				     SolarisInstallResources.MSG_CAPACITY), 
		    Label.RIGHT);	// "Capacity:"
      l.setFont(font);
      southEast.add("Label", l);
      l = new Label( diskSize +
		     MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				      SolarisInstallResources.MSG_MB), Label.LEFT); // "MB "
      l.setFont(font);
      l.setForeground(Color.blue);
      southEast.add("Field", l);
      
      l = new Label(MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				     SolarisInstallResources.MSG_ALLOCATED), 
		    Label.RIGHT);	// "Allocated:"
      l.setFont(font);
      southEast.add("Label", l);
    
      allocLabel = new Label(usedSpace +
			     MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
					      SolarisInstallResources.MSG_MB), 
			     Label.LEFT); // "MB "
      allocLabel.setFont(font);
      allocLabel.setForeground(Color.blue);
      southEast.add("Field", allocLabel);
      
      l = new Label(MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				     SolarisInstallResources.MSG_FREE), 
		    Label.RIGHT);	// "Free:"
      l.setFont(font);
      southEast.add("Label", l);
      freeLabel = new Label(freeSpace +
			    MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
					     SolarisInstallResources.MSG_MB), 
			    Label.LEFT); // "MB "
      if (freeSpace >= 0)
	freeLabel.setForeground(Color.blue);
      else
	freeLabel.setForeground(Color.red);
      freeLabel.setFont(font);
      southEast.add("Field", freeLabel);

      l = new Label(MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				     SolarisInstallResources.MSG_ROUNDING_ERROR),
		    Label.RIGHT);
      l.setFont(font);
      southEast.add("Label", l);
      roundLabel = new Label(String.valueOf(roundErr) +
			     MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
					      SolarisInstallResources.MSG_MB), 
			     Label.LEFT); // "MB "
      if (roundErr >= 0)
	roundLabel.setForeground(Color.blue);
      else 
	roundLabel.setForeground(Color.red);
    
      roundLabel.setFont(font);
      southEast.add("Field", roundLabel);

      south.add("East", southEast);
      out.add("South", south);
      return out;
    }

 private Panel createSliceCylPanel()
    {
      int numSlices = tableManager.getNumSlices(diskName);
      int freeSpaceCyls = tableManager.getFreeSpaceCyls(diskName);
      int diskSizeCyls = tableManager.getDiskSizeCyls(diskName);
      int usedSpaceCyls = diskSizeCyls - freeSpaceCyls;
      int nextAvailCyl = tableManager.getNextAvailableCyl( diskName );

      Panel out = new Panel();
      out.setLayout(new BorderLayout(0, 15));
      
      Panel table = new Panel();
      table.setLayout(new ColumnLayout());

      fsnamesCyls = new FilteredTextField[numSlices];
      fsstartCyl = new FilteredTextField[numSlices];
      fssizesCyls = new FilteredTextField[numSlices];
      minsizeCyls = new MinSizeLabel[numSlices];

      Font font = new Font("Dialog", Font.BOLD, 12);
      Label l = 
	new Label(MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
			SolarisInstallResources.MSG_SLICE_HEADER_CYLS));
      l.setFont(font);
      table.add(l);
      for (int i = 0; i < numSlices; i++) {
	if (i == 2) {
	  i++;
	}
	
	Panel row = new Panel();
	row.setLayout(new RowLayout(LAYOUT_ALIGNMENT.CENTER, 20,0));
	
	fsnamesCyls[i] = new FilteredTextField(15);
	fsnamesCyls[i].addDeniedCharacters(" ");
	fsnamesCyls[i].setName(String.valueOf(i));
	
	fsstartCyl[i] = new FilteredTextField("", 5, 100,
					       FilteredTextField.TYPE_NUMERIC);
	fsstartCyl[i].setName("start " + i);
	//fsstartCyl[i].setName(String.valueOf(i));

	fssizesCyls[i] = new FilteredTextField("", 5, 100,
					       FilteredTextField.TYPE_NUMERIC);
	fssizesCyls[i].setName(String.valueOf(i));
	
	minsizeCyls[i] = new MinSizeLabel("");
	
	fsnamesCyls[i].addFocusListener(this);
	fssizesCyls[i].addFocusListener(this);
	fsstartCyl[i].addFocusListener(this);

	if (!tableManager.getSliceName(diskName, i).equals("")) { 
	  fsnamesCyls[i].setText(tableManager.getSliceName(diskName, i));
	  
	  int start = tableManager.getSliceStartCyl(diskName, i);
	  fsstartCyl[i].setText(String.valueOf(start));

	  int min = tableManager.getSliceMinSizeCyls(diskName, i);

	  fssizesCyls[i].setText(String.valueOf(min));

	  if (min == 0) {
	    minsizeCyls[i].setAlignment(Label.CENTER);
	    minsizeCyls[i].setText("");
	  } else {
	    minsizeCyls[i].setAlignment(Label.CENTER);
	    minsizeCyls[i].setText(String.valueOf(min) +
		MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
			SolarisInstallResources.MSG_SINGLESPACE_CYLS));
	  }
	  fssizesCyls[i].setText(String.valueOf(
		       tableManager.getSliceSizeCyls(diskName, i)));
	  
	  if (tableManager.isDefaultSwapSlice(diskName, i)) {
	    fsnamesCyls[i].setEditable(false);
	    fssizesCyls[i].setEditable(false);
	    fsstartCyl[i].setEditable(false);
	    minsizeCyls[i].setAlignment(Label.CENTER);
	    minsizeCyls[i].setText("");
	    fsnamesCyls[i].removeFocusListener(this);
	    fssizesCyls[i].removeFocusListener(this);
	    fsstartCyl[i].removeFocusListener(this);
	  }
	}
      
	row.add(new Label(" " + String.valueOf(i), Label.CENTER));
	row.add(fsnamesCyls[i]);
	row.add(fsstartCyl[i]);
	row.add(fssizesCyls[i]);
	row.add(minsizeCyls[i]);
	table.add(row);
      }

      Panel insetp = new Panel();
      insetp.setLayout(new BorderLayout());
      insetp.add("Center", table);
      out.add("Center", insetp);

      Object[] msgArgs = {diskName, new Integer(diskSizeCyls)};
      l = new Label(MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				     SolarisInstallResources.MSG_DISK_IN_CYLS,
				     msgArgs));
      l.setBackground(Color.blue);
      l.setForeground(Color.white);
      l.setFont(new Font(font.getName(), font.BOLD, 14));
      out.add("North", l);
      
      Panel south = new Panel();
      south.setLayout(new BorderLayout());
    
      Panel southEast = new Panel();
      southEast.setLayout(new FieldLayout(5,0));

      l = new Label(MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				     SolarisInstallResources.MSG_CAPACITY), 
		    Label.RIGHT);	// "Capacity:"
      l.setFont(font);
      southEast.add("Label", l);
      l = new Label( diskSizeCyls +
		     MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				      SolarisInstallResources.MSG_CYLS),
		     Label.LEFT); // "Cyls "
      l.setFont(font);
      l.setForeground(Color.blue);
      southEast.add("Field", l);
      
      l = new Label(MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				     SolarisInstallResources.MSG_ALLOCATED), 
		    Label.RIGHT);	// "Allocated:"
      l.setFont(font);
      southEast.add("Label", l);
    
      allocLabelCyls =
	new Label(usedSpaceCyls +
		  MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				   SolarisInstallResources.MSG_CYLS), 
		  Label.LEFT); // "Cyls "
      allocLabelCyls.setFont(font);
      allocLabelCyls.setForeground(Color.blue);
      southEast.add("Field", allocLabelCyls);
      
      l = new Label(MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				     SolarisInstallResources.MSG_FREE), 
		    Label.RIGHT);	// "Free:"
      l.setFont(font);
      southEast.add("Label", l);
      freeLabelCyls =
	new Label(freeSpaceCyls +
		  MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				   SolarisInstallResources.MSG_CYLS), 
		  Label.LEFT); // "Cyls "
      freeLabelCyls.setForeground(Color.blue);
      freeLabelCyls.setFont(font);
      southEast.add("Field", freeLabelCyls);

      south.add("East", southEast);
      out.add("South", south);
      return out;
    }


  public void actionPerformed( ActionEvent ae ) {    
    Object target = ae.getSource();
    if( target == okButton ) {
      if( apply() ) {
	this.setVisible( false );
      }
    } else if( target == applyButton ) {
      apply();
    } else if( target == cancelButton ) {
      tableManager.cancel( this );
      this.setVisible( false );
    } else if( target == resetButton ) {
      tableManager.cancel( this );
    } else if (target == mbButton) {
      //switch to cylinder mode
      mbButton.setEnabled(false);
      cylButton.setEnabled(true);
      cardLayout.first(cardPanel);
      currentMode = DiskTableManager.MB_MODE;
    } else if (target == cylButton) {
      //switch to mb mode
      cardLayout.last(cardPanel);
      cylButton.setEnabled(false);
      mbButton.setEnabled(true);
      currentMode = DiskTableManager.CYL_MODE;
    }
  }

  public boolean apply() {
    try {
      Vector warnings = tableManager.commit(this);
      if( !once && warnings.size() != 0 ) {
	showErrors( warnings );
	once = true;
	return false;
      }
    } catch( DiskTableException dte ) {
      dte.printStackTrace();
      Vector errors = dte.getErrors();
      showErrors( errors );
      return false;
    } 
    
    return true;
  }

  private void showErrors( Vector errors ) 
    {
      if( msgDialog == null ) {
	msgDialog =
	  new MessageFrame(this,
		      MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				SolarisInstallResources.MSG_NO_CHANGES_APPLIED),
			   errors);
	WindowAdapter wa = new WindowAdapter() {
	  public void windowClosed(WindowEvent e) {
	    msgDialog = null;
	  }
	};
	msgDialog.addWindowListener( wa );
      }
    }
  

  public void focusGained(FocusEvent e) {}
  public void focusLost(FocusEvent e) {
    Object o = e.getSource();
    Component c = e.getComponent();
    if( (o instanceof IntegerField) || (o instanceof TextField) ) {
      DiskTableEvent dte;
      if (currentMode == DiskTableManager.MB_MODE) {
	int idx = Integer.parseInt( ((Component) o).getName() );
	String newname = fsnames[idx].getText();
	int newsize = DiskTableEvent.NO_SIZE;	
	try {
	  newsize = Integer.parseInt(fssizes[idx].getText());
	} catch( NumberFormatException nfe ) {
	}
	
	dte = 
	  tableManager.current(diskName, idx, this);
	dte.setSliceName(newname);
	dte.setSliceSize(newsize);
	dte.setSliceSizeCyls(tableManager.convertMbToCyls(dte.getName(), 
							  newsize));
      } else { // CYLMODE
	boolean isStartField = false;
	String tmpIdx = ((Component) o).getName();
	int idx = -1;
	if (tmpIdx.startsWith("start")) {
	  isStartField = true;
	  // prune of the "start "
	  idx = Integer.parseInt(tmpIdx.substring(6));
	} else {
	  isStartField = false;
	  idx = Integer.parseInt(tmpIdx);
	}	
	String newname = fsnamesCyls[idx].getText();
	dte = 
	  tableManager.current(diskName, idx, this);
	if (!isStartField) {
	  int newsize = DiskTableEvent.NO_SIZE;
	  try {	  
	    newsize = Integer.parseInt(fssizesCyls[idx].getText());
	  } catch( NumberFormatException nfe ) {
	  }
	  dte.setSliceSizeCyls(newsize);
	  dte.setSliceSize(tableManager.convertCylsToMb(dte.getName(),
							newsize));
	} else {
	  int newstart = DiskTableEvent.NO_SIZE;
	  try {	 
	    newstart = Integer.parseInt(fsstartCyl[idx].getText());	   
	  } catch( NumberFormatException nfe ) {
	  }
	  dte.setStartCyl(newstart);
	}
	dte.setSliceName(newname);
      }
      try {
	tableManager.changeTable( dte, this, currentMode);
	dte = 
	  tableManager.current(diskName, dte.getSliceNum(), this);
	updateSouth(dte);
      } catch( DiskTableException ex) {
	ex.printStackTrace();
	Vector errors = ex.getErrors();
	showErrors( errors );
      }
    }
  }

  private void updateSouth(DiskTableEvent dte) {
    int freeSpace = dte.getFreeSpace();
      int freeSpaceCyls = dte.getFreeSpaceCyls();
      int roundErr = dte.getRoundError();

      roundLabel.setText(String.valueOf(roundErr)+
		MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				 SolarisInstallResources.MSG_SINGLESPACE_MB));

       if (roundErr >= 0)
 	roundLabel.setForeground(Color.blue);
       else 
 	roundLabel.setForeground(Color.red);

       freeLabel.setText(String.valueOf(freeSpace) +
		MsgCat.getString("com.sun.solarisinstall.SolarisInstall",
				 SolarisInstallResources.MSG_SINGLESPACE_MB));

       if (freeSpace >= 0)
	 freeLabel.setForeground(Color.blue);
       else 
 	freeLabel.setForeground(Color.red);
      
      freeLabelCyls.setText(String.valueOf(freeSpaceCyls) +
	 	MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				 SolarisInstallResources.MSG_CYLS));
      
      if (freeSpaceCyls >= 0)
 	freeLabelCyls.setForeground(Color.blue);
      else 
 	freeLabelCyls.setForeground(Color.red);
       allocLabel.setText((tableManager.getDiskSize(diskName) -
		freeSpace) +
		MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				 SolarisInstallResources.MSG_SINGLESPACE_MB));
       allocLabelCyls.setText((tableManager.getDiskSizeCyls(diskName) - 
	 	 freeSpaceCyls) +
		 MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				  SolarisInstallResources.MSG_CYLS));
  }

  public void tableUpdate( DiskTableEvent dte ) {
    if( dte.getName().equals(diskName) ) {			  
      int index = dte.getSliceNum();
      if((index != DiskTableEvent.OVERLAP_SLICE) &&
	 (index != DiskTableEvent.NO_SLICE)) {
	  fsnames[index].setText(dte.getSliceName());
	  fsnamesCyls[index].setText(dte.getSliceName());
	if( dte.getSliceSize() != DiskTableEvent.NO_SIZE ) {
	    fssizes[index].setText(String.valueOf(dte.getSliceSize()));
	    fssizesCyls[index].setText(String.valueOf(dte.getSliceSizeCyls()));
	} else {
	  fssizes[index].setText("");
	  fssizesCyls[index].setText("");
	}
	
	if (dte.getStartCyl() != DiskTableEvent.NO_SIZE) {
	  fsstartCyl[index].setText(String.valueOf(dte.getStartCyl()));
	} else {
	  fsstartCyl[index].setText("");
	}
	int min = dte.getSliceMinSize();
	
	if( min == DiskTableEvent.NO_MINIMUM ) {
	  minsize[index].setText("");
	} else {
	  minsize[index].setText(String.valueOf(min) + 
		  MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
				  SolarisInstallResources.MSG_SINGLESPACE_MB));
	}
	int minCyls = dte.getSliceMinSizeCyls();
	if( minCyls == DiskTableEvent.NO_MINIMUM ) {
	  minsizeCyls[index].setText("");
	} else {
	  minsizeCyls[index].setText(String.valueOf(minCyls) + 
		MsgCat.getString("com.sun.solarisinstall.SolarisInstall", 
			       SolarisInstallResources.MSG_SINGLESPACE_CYLS));
	}
      }
      
    }
  }

  class MinSizeLabel extends Label {
    private int minWidth = 70;
   
    public MinSizeLabel() { super(); }
    public MinSizeLabel(String label) { super(label); }
    public MinSizeLabel(String label, int alignment) { super(label,
							     alignment); }
    public MinSizeLabel(String label, int alignment, int min) {
      super(label, alignment);
      minWidth = min;
    }
    
    public Dimension getMinimumSize() {
      Dimension d = super.getMinimumSize();
      d.width = Math.max(minWidth, d.width);
      return(d);
    }
    
    public Dimension getPreferredSize() {
      Dimension d = super.getPreferredSize();
      d.width = Math.max(minWidth, d.width);
      return(d);
    }
    
    public void setMinWidth(int min) { minWidth = min; }
    public int getMinWidth() { return minWidth; }
  }
}
