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