001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2006-2009 Sun Microsystems, Inc. 015 * Portions Copyright 2013-2015 ForgeRock AS. 016 */ 017package org.opends.quicksetup.installer.ui; 018 019import org.forgerock.i18n.LocalizableMessage; 020import static org.opends.messages.QuickSetupMessages.*; 021 022import java.awt.Component; 023import java.awt.GridBagConstraints; 024import java.awt.GridBagLayout; 025import java.awt.event.ActionEvent; 026import java.awt.event.ActionListener; 027import javax.swing.*; 028 029import org.opends.quicksetup.ui.GuiApplication; 030import org.opends.quicksetup.ui.QuickSetupStepPanel; 031import org.opends.quicksetup.ui.UIFactory; 032import org.opends.quicksetup.LicenseFile; 033import org.opends.quicksetup.ButtonName; 034 035/** 036 * This panel is used to show a welcome message. 037 * 038 */ 039public class InstallLicensePanel extends QuickSetupStepPanel 040{ 041 private static final long serialVersionUID = 6209217138897900860L; 042 043 /** 044 * Default constructor. 045 * @param app Application this panel represents 046 */ 047 public InstallLicensePanel(GuiApplication app) 048 { 049 super(app); 050 } 051 052 /** {@inheritDoc} */ 053 protected LocalizableMessage getTitle() 054 { 055 return INFO_LICENSE_PANEL_TITLE.get(); 056 } 057 058 /** {@inheritDoc} */ 059 protected LocalizableMessage getInstructions() 060 { 061 return null; 062 } 063 064 private JCheckBox acceptCheck; 065 066 /** {@inheritDoc} */ 067 protected Component createInputPanel() 068 { 069 // No input in this panel 070 JPanel panel = new JPanel(new GridBagLayout()); 071 panel.setOpaque(false); 072 073 GridBagConstraints gbc = new GridBagConstraints(); 074 075 gbc.insets = UIFactory.getEmptyInsets(); 076 gbc.anchor = GridBagConstraints.NORTHWEST; 077 gbc.gridwidth = GridBagConstraints.REMAINDER; 078 gbc.weightx = 1.0; 079 gbc.fill = GridBagConstraints.HORIZONTAL; 080 081 JLabel l = 082 UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, 083 INFO_LICENSE_DETAILS_LABEL.get(), 084 UIFactory.TextStyle.SECONDARY_FIELD_VALID); 085 086 gbc.insets = UIFactory.getEmptyInsets(); 087 gbc.insets.bottom = 3; 088 panel.add(l, gbc); 089 090 JTextArea detailsTextArea = new JTextArea(10, 50); 091 detailsTextArea.setBackground( 092 UIFactory.CURRENT_STEP_PANEL_BACKGROUND); 093 detailsTextArea.setFont(UIFactory.TEXTFIELD_FONT); 094 detailsTextArea.setText(LicenseFile.getText()); 095 096 gbc.insets = UIFactory.getEmptyInsets(); 097 gbc.fill = GridBagConstraints.BOTH; 098 gbc.weighty = 1.0; 099 panel.add(new JScrollPane(detailsTextArea), gbc); 100 101 acceptCheck = UIFactory.makeJCheckBox(INFO_LICENSE_CLICK_LABEL.get(), 102 null, 103 UIFactory.TextStyle.SECONDARY_FIELD_VALID); 104 acceptCheck.setOpaque(false); 105 acceptCheck.setSelected(false); 106 107 gbc.insets = UIFactory.getEmptyInsets(); 108 gbc.insets.top = UIFactory.TOP_INSET_RADIO_SUBORDINATE; 109 gbc.fill = GridBagConstraints.BOTH; 110 gbc.weighty = 0.0; 111 panel.add(acceptCheck, gbc); 112 113 addActionListeners(); 114 115 return panel; 116 } 117 118 /** {@inheritDoc} */ 119 protected boolean requiresScroll() 120 { 121 return false; 122 } 123 124 /** 125 * Adds the required action listeners to the fields. 126 */ 127 private void addActionListeners() 128 { 129 final ActionListener l = new ActionListener() 130 { 131 public void actionPerformed(ActionEvent e) 132 { 133 // Enable or disable Next button as user clicks approval button 134 getQuickSetup().getDialog().setButtonEnabled( 135 ButtonName.NEXT, acceptCheck.isSelected()); 136 137 // Save approval status for navigation 138 LicenseFile.setApproval(acceptCheck.isSelected()); 139 } 140 }; 141 142 acceptCheck.addActionListener(l); 143 } 144}