001/* 002 * IzPack - Copyright 2001-2005 Julien Ponge, All Rights Reserved. 003 * 004 * http://www.izforge.com/izpack/ 005 * http://developer.berlios.de/projects/izpack/ 006 * 007 * Copyright 2005 Klaus Bartz 008 * 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 */ 021 022package com.izforge.izpack.panels; 023 024import java.awt.GridBagConstraints; 025import java.awt.GridBagLayout; 026import java.awt.Insets; 027 028import javax.swing.JEditorPane; 029import javax.swing.JScrollPane; 030 031import com.izforge.izpack.installer.InstallData; 032import com.izforge.izpack.installer.InstallerFrame; 033import com.izforge.izpack.installer.IzPanel; 034import com.izforge.izpack.util.MultiLineLabel; 035import com.izforge.izpack.util.SummaryProcessor; 036 037/** 038 * Summary panel to use before InstallPanel. This panel calls the {@link SummaryProcessor} which 039 * calls all declared panels for a summary and shows the given captiond and messaged in a 040 * <code>JEditorPane</code>. 041 * 042 * @author Klaus Bartz 043 * 044 */ 045public class SummaryPanel extends IzPanel 046{ 047 048 /** 049 * 050 */ 051 private static final long serialVersionUID = 3832626166401282361L; 052 053 /** The text area. */ 054 private JEditorPane textArea; 055 056 /** 057 * The constructor. 058 * 059 * @param parent The parent. 060 * @param idata The installation data. 061 */ 062 public SummaryPanel(InstallerFrame parent, InstallData idata) 063 { 064 super(parent, idata); 065 // We initialize our layout 066 GridBagLayout layout = new GridBagLayout(); 067 GridBagConstraints gbConstraints = new GridBagConstraints(); 068 setLayout(layout); 069 MultiLineLabel introLabel = createMultiLineLabelLang("SummaryPanel.info"); 070 parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 1.0, 0.0); 071 gbConstraints.insets = new Insets(0, 0, 20, 0); 072 gbConstraints.fill = GridBagConstraints.NONE; 073 gbConstraints.anchor = GridBagConstraints.SOUTHWEST; 074 add(introLabel, gbConstraints); 075 076 try 077 { 078 textArea = new JEditorPane(); 079 textArea.setContentType("text/html"); 080 textArea.setEditable(false); 081 JScrollPane scroller = new JScrollPane(textArea); 082 parent.buildConstraints(gbConstraints, 0, 1, 1, 1, 1.0, 1.0); 083 gbConstraints.anchor = GridBagConstraints.CENTER; 084 gbConstraints.fill = GridBagConstraints.BOTH; 085 add(scroller, gbConstraints); 086 } 087 catch (Exception err) 088 { 089 err.printStackTrace(); 090 } 091 } 092 093 /* 094 * (non-Javadoc) 095 * 096 * @see com.izforge.izpack.installer.IzPanel#panelActivate() 097 */ 098 public void panelActivate() 099 { 100 super.panelActivate(); 101 textArea.setText(SummaryProcessor.getSummary(idata)); 102 textArea.setCaretPosition(0); 103 } 104 105}