package wizard; import install.Main; import java.awt.BorderLayout; 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/update type options panel for GetBIRCH. * * On this panel, the user can choose whether they wish to perform a default * or an advanced installation/update of BIRCH. ** * @author Graham Alvare * @author Dale Hamel * @author Brian Fristensky */ public class TypePanel extends WizardPanel { /** * This radio button is used in conjunction with 'advancedButton' * for determining whether to perform an advanced or default * installation/update of BIRCH. * * If defaultButton is selected, * a default BIRCH installation/update will be performed * If advancedButton is selected, * an advanced BIRCH installation/update will be performed */ private final JRadioButton defaultButton = new JRadioButton("Default install/update (from network)", true); /** * This radio button is used in conjunction with 'defaultButton' * for determining whether to perform an advanced or default * installation/update of BIRCH. * * If defaultButton is selected, * a default BIRCH installation/update will be performed * If advancedButton is selected, * an advanced BIRCH installation/update will be performed */ private final JRadioButton advancedButton = new JRadioButton("Advanced install/update", false); /** * The general installation/update parameters selected, if the user * decides to perform a default BIRCH installation/update. This will * change, if the user modifies the advanced installation/update options! */ JTextArea installStatus = new JTextArea(); /** * The serialization UID for the installation type panel. */ private static final long serialVersionUID = 1L; /** * Create a new install/update type selection panel ** * @param wizard the installation wizard object to attach the panel to */ public TypePanel(BIRCHWizard wizard) { // copy function parameters to class variables ButtonGroup bgroup = null; JLabel iconLabel = new JLabel(new ImageIcon((URL) TypePanel.class.getResource("dna.jpg"))); JLabel barLabel = new JLabel("-------------------------------------------------------------------------"); JLabel typeSelectionLabel = new JLabel("Please choose default or advanced install/update type"); JPanel contentPanel = new JPanel(); // configure the two install type buttons bgroup = new ButtonGroup(); bgroup.add(defaultButton); bgroup.add(advancedButton); // configure the bounds of the different components on the screen typeSelectionLabel.setBounds ( 15, 15, 476, 27 ); defaultButton.setBounds ( 17, 57, 370, 17 ); installStatus.setBounds ( 15, 75, 467, 114 ); barLabel.setBounds ( 18, 197, 465, 26 ); advancedButton.setBounds ( 16, 220, 368, 17 ); // configure the installation/update type text area installStatus.setEditable(false); // configure the main content panel contentPanel.setLayout(null); contentPanel.setSize(512, 344); // add the components to the main content panel contentPanel.add(defaultButton, null); contentPanel.add(advancedButton, null); contentPanel.add(typeSelectionLabel, null); contentPanel.add(installStatus, 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) { defaultButton.setText("Default install/update (from disc)"); } // set the action listeners for the default vs. advanced install/update defaultButton.addActionListener(wizard.changeNextToFinishAction); advancedButton.addActionListener(wizard.changeFinishToNextAction); } /** * Returns whether an advanced installation should be performed, or a * default installation/update. ** * @return true if an advanced install/update should be performed */ public boolean isAdvancedInstall() { return advancedButton.isSelected(); } /** * 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/update (as opposed to the "Next" button) ** * @return whether to complete the install/update process */ @Override public boolean isFinished() { return defaultButton.isSelected(); } /** * This method checks for errors in the current install wizard panel ** * @return true if there are no errors in the current panel */ @Override public boolean errorCheck() { return true; } }