package wizard; import install.Main; import java.awt.BorderLayout; import java.awt.Rectangle; import java.awt.Dimension; import java.awt.Insets; import java.net.URL; import javax.swing.ButtonGroup; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JTextArea; import javax.swing.border.EmptyBorder; import javax.swing.border.EtchedBorder; /** * The install type options panel for GetBIRCH. * * On this panel, the user can choose whether they wish to perform a default * or an advanced installation of BIRCH. * * This installation type options panel will only be displayed if the user * chooses to perform an installation instead of an update. ** * @author Graham Alvare * @author Dale Hamel * @author Brian Fristensky */ public class InstallTypePanel extends WizardPanel { /** * This radio button is used in conjunction with 'advancedInstallButton' * for determining whether to perform an advanced or default installation * of BIRCH. * * If defaultInstallButton is selected, * a default BIRCH installation will be performed * If advancedInstallButton is selected, * an advanced BIRCH installation will be performed */ private final JRadioButton defaultInstallButton = new JRadioButton("Default install (from network)", true); /** * This radio button is used in conjunction with 'defaultInstallButton' * for determining whether to perform an advanced or default installation * of BIRCH. * * If defaultInstallButton is selected, * a default BIRCH installation will be performed * If advancedInstallButton is selected, * an advanced BIRCH installation will be performed */ private final JRadioButton advancedInstallButton = new JRadioButton("Advanced install", false); /** * The general installation parameters selected, if the user decides to * perform a default BIRCH installation. This will change, if the user * modifies the advanced installation options! */ JTextArea installStatusText = new JTextArea(); /** * The serialization UID for the installation type panel. */ private static final long serialVersionUID = 1L; /** * Create a new install type selection panel ** * @param wizard the installation wizard object to attach the panel to */ public InstallTypePanel(BIRCHWizard wizard) { // copy function parameters to class variables ButtonGroup bgroup = null; JLabel iconLabel = new JLabel(new ImageIcon((URL) InstallTypePanel.class.getResource("dna.jpg"))); JLabel barLabel = new JLabel("-------------------------------------------------------------------------"); JLabel installSelectionLabel = new JLabel("Please choose default or advanced install type"); JPanel contentPanel = new JPanel(); // configure the two install type buttons bgroup = new ButtonGroup(); bgroup.add(defaultInstallButton); bgroup.add(advancedInstallButton); // configure the bounds of the different labels on the screen barLabel.setBounds(new Rectangle(18, 197, 465, 26)); installSelectionLabel.setBounds(new Rectangle(15, 15, 476, 27)); defaultInstallButton.setBounds(new Rectangle(17, 57, 370, 17)); advancedInstallButton.setBounds(new Rectangle(16, 220, 368, 17)); // configure the installation type text area installStatusText.setBounds(new Rectangle(15, 75, 467, 114)); installStatusText.setEditable(false); // configure the main content panel contentPanel.setLayout(null); contentPanel.setSize(new Dimension(512, 344)); // add the components to the main content panel contentPanel.add(defaultInstallButton, null); contentPanel.add(advancedInstallButton, null); contentPanel.add(installSelectionLabel, null); contentPanel.add(installStatusText, null); contentPanel.add(barLabel, null); // further configure the main content panel contentPanel.setVisible(true); contentPanel.setBorder(new EmptyBorder(new Insets(10, 10, 10, 10))); // prepare the current panel for display setLayout(new java.awt.BorderLayout()); iconLabel.setBorder(new EtchedBorder(EtchedBorder.RAISED)); add(iconLabel, BorderLayout.WEST); add(contentPanel, BorderLayout.CENTER); if (Main.DISC_INSTALL) { defaultInstallButton.setText("Default install (from disc)"); } // set the action listeners for the default vs. advanced install defaultInstallButton.addActionListener(wizard.changeNextToFinishAction); advancedInstallButton.addActionListener(wizard.changeFinishToNextAction); } /** * Determines whether this step is sufficient to complete the install wizard * Returns whether or not to display the "Finish" button for this step of * the installation (as opposed to the "Next" button) ** * @return whether to complete the install process */ public boolean isFinished() { return defaultInstallButton.isSelected(); } /** * Returns whether an advanced installation should be performed, or a * default installation. ** * @return true if an advanced install should be performed */ public boolean isAdvancedInstall() { return advancedInstallButton.isSelected(); } }