home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
VCAFE.3.0A
/
Main.bin
/
WizardSummaryPanel.java
< prev
next >
Wrap
Text File
|
1998-11-24
|
5KB
|
146 lines
package com.symantec.itools.frameworks.wizard;
import java.awt.*;
import java.util.Enumeration;
import java.util.Vector;
import com.sun.java.swing.JScrollPane;
import com.symantec.itools.swing.JWrappingLabel;
import com.sun.java.swing.JTable;
import com.sun.java.swing.table.*;
import com.symantec.itools.swing.models.StringTableModel;
import com.symantec.itools.util.ResourceBundleAdapter;
import java.util.ResourceBundle;
/**
* @author Symantec Internet Tools Division
* @version 2.0
* @since VCafe 3.0
*/
public class WizardSummaryPanel
extends WizardPanel
{
protected ResourceBundleAdapter resourceBundle;
protected com.sun.java.swing.JScrollPane scrollPane = new com.sun.java.swing.JScrollPane();
protected com.sun.java.swing.JTable summaryTbl = new com.sun.java.swing.JTable();
protected com.symantec.itools.swing.models.StringTableModel summaryTblModel = new com.symantec.itools.swing.models.StringTableModel();
protected com.symantec.itools.swing.JWrappingLabel label;
protected static ResourceBundle defaultResourceBundle;
static
{
try
{
defaultResourceBundle = ResourceBundle.getBundle("com.symantec.itools.frameworks.wizard.WizardResource");
}
catch(Throwable ex)
{
ex.printStackTrace();
}
}
protected final static int MIN_ROWS = 14;
public WizardSummaryPanel()
{
this(defaultResourceBundle);
}
public WizardSummaryPanel(ResourceBundle bundle)
{
resourceBundle = new ResourceBundleAdapter(bundle);
label = new com.symantec.itools.swing.JWrappingLabel(resourceBundle.getString("SP_Description"));
setLayout(null);
setSize(444,349);
label.setBounds(20,15,250,22);
add(label);
add(scrollPane, "South");
scrollPane.setBounds(20,40,430,260);
summaryTbl.setModel(summaryTblModel);
summaryTblModel.setEditable(false);
summaryTblModel.setColumnHeaders(resourceBundle.getString("SP_Option") + "," + resourceBundle.getString("SP_Choice"));
scrollPane.getViewport().add(summaryTbl);
summaryTbl.setBounds(20,40,430,260);
summaryTbl.setColumnSelectionAllowed(false);
summaryTbl.setRowSelectionAllowed(false);
summaryTbl.setCellSelectionEnabled(false);
summaryTbl.setEnabled(false);
summaryTbl.getTableHeader().setReorderingAllowed(false);
}
public String getPanelTitle()
{
return resourceBundle.getString("SP_Title");
}
/**
* Called by controller before the panel is displayed.
* Only current panel is called.
* @since VCafe 3.0
*/
public void entering()
{
Vector summaries;
Vector summariesData;
String[] data;
summaries = controller.getWizardSummary();
summariesData = new Vector();
// Put summaries into summaryContainerPanel
int max = summaries.size();
for(int i = 0; i < max; i++)
{
WizardSummary summary = (WizardSummary)summaries.elementAt(i);
addWizardSummary(summary, summariesData);
}
addPadRows(summariesData);
controller.getWizard().setNextEnabled(false);
data = new String[summariesData.size()];
summariesData.copyInto(data);
summaryTblModel.setItems(data);
//summaryTbl.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
TableColumn keyColumn, valueColumn;
TableColumnModel columnModel = summaryTbl.getColumnModel();
keyColumn = columnModel.getColumn(0);
valueColumn = columnModel.getColumn(1);
valueColumn.setWidth(400);
keyColumn.setWidth(200);
}
protected void addWizardSummary(WizardSummary summary, Vector data)
{
boolean hasSummaries = false;
for(Enumeration e = summary.getSummaryItems(); e.hasMoreElements();)
{
addWizardSummaryItem((WizardSummary.Item)e.nextElement(), data);
hasSummaries = true;
}
if (hasSummaries) {
data.addElement(",");
}
}
protected void addWizardSummaryItem(WizardSummary.Item item, Vector data)
{
String key = item.getKey().replace(',', ' '); // note: commas not allowed currently
if (key == null)
key = "";
String val = item.getValue().replace(',', ' ');
if (val == null)
val = "";
data.addElement(key + ',' + val);
}
protected void addPadRows(Vector data)
{
int rowCount = data.size();
while (rowCount < MIN_ROWS) {
data.addElement(",");
rowCount++;
}
}
}