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 2002 Jan Blok 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; 027import java.util.ArrayList; 028 029import javax.swing.Box; 030import javax.swing.BoxLayout; 031import javax.swing.JLabel; 032import javax.swing.JPanel; 033 034import com.izforge.izpack.Info; 035import com.izforge.izpack.gui.LabelFactory; 036import com.izforge.izpack.installer.InstallData; 037import com.izforge.izpack.installer.InstallerFrame; 038import com.izforge.izpack.installer.IzPanel; 039 040/** 041 * The Hello panel class. 042 * 043 * @author Julien Ponge 044 */ 045public class HelloPanel extends IzPanel 046{ 047 048 /** 049 * 050 */ 051 private static final long serialVersionUID = 3257848774955905587L; 052 053 /** The layout. */ 054 private BoxLayout layout; 055 056 /** The welcome label. */ 057 private JLabel welcomeLabel; 058 059 /** The application authors label. */ 060 private JLabel appAuthorsLabel; 061 062 /** The application URL label. */ 063 private JLabel appURLLabel; 064 065 /** 066 * The constructor. 067 * 068 * @param parent The parent. 069 * @param idata The installation data. 070 */ 071 public HelloPanel(InstallerFrame parent, InstallData idata) 072 { 073 super(parent, idata); 074 075 // The 'super' layout 076 GridBagLayout superLayout = new GridBagLayout(); 077 setLayout(superLayout); 078 GridBagConstraints gbConstraints = new GridBagConstraints(); 079 gbConstraints.insets = new Insets(0, 0, 0, 0); 080 gbConstraints.fill = GridBagConstraints.NONE; 081 gbConstraints.anchor = GridBagConstraints.CENTER; 082 083 // We initialize our 'real' layout 084 JPanel centerPanel = new JPanel(); 085 layout = new BoxLayout(centerPanel, BoxLayout.Y_AXIS); 086 centerPanel.setLayout(layout); 087 superLayout.addLayoutComponent(centerPanel, gbConstraints); 088 add(centerPanel); 089 090 // We create and put the labels 091 String str; 092 093 centerPanel.add(Box.createVerticalStrut(10)); 094 095 str = parent.langpack.getString("HelloPanel.welcome1") + idata.info.getAppName() + " " 096 + idata.info.getAppVersion() + parent.langpack.getString("HelloPanel.welcome2"); 097 welcomeLabel = LabelFactory.create(str, parent.icons.getImageIcon("host"), JLabel.TRAILING); 098 centerPanel.add(welcomeLabel); 099 100 centerPanel.add(Box.createVerticalStrut(20)); 101 102 ArrayList authors = idata.info.getAuthors(); 103 int size = authors.size(); 104 if (size > 0) 105 { 106 str = parent.langpack.getString("HelloPanel.authors"); 107 appAuthorsLabel = LabelFactory.create(str, parent.icons.getImageIcon("information"), 108 JLabel.TRAILING); 109 centerPanel.add(appAuthorsLabel); 110 111 JLabel label; 112 for (int i = 0; i < size; i++) 113 { 114 Info.Author a = (Info.Author) authors.get(i); 115 String email = (a.getEmail() != null && a.getEmail().length() > 0) ? (" <" + a.getEmail() + ">") : ""; 116 label = LabelFactory.create(" - " + a.getName() + email, parent.icons 117 .getImageIcon("empty"), JLabel.TRAILING); 118 centerPanel.add(label); 119 } 120 121 centerPanel.add(Box.createVerticalStrut(20)); 122 } 123 124 if (idata.info.getAppURL() != null) 125 { 126 str = parent.langpack.getString("HelloPanel.url") + idata.info.getAppURL(); 127 appURLLabel = LabelFactory.create(str, parent.icons.getImageIcon("bookmark"), 128 JLabel.TRAILING); 129 centerPanel.add(appURLLabel); 130 } 131 } 132 133 /** 134 * Indicates wether the panel has been validated or not. 135 * 136 * @return Always true. 137 */ 138 public boolean isValidated() 139 { 140 return true; 141 } 142}