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-2016 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/** This panel is used to show a welcome message. */ 036public class InstallLicensePanel extends QuickSetupStepPanel 037{ 038 private static final long serialVersionUID = 6209217138897900860L; 039 040 /** 041 * Default constructor. 042 * @param app Application this panel represents 043 */ 044 public InstallLicensePanel(GuiApplication app) 045 { 046 super(app); 047 } 048 049 @Override 050 protected LocalizableMessage getTitle() 051 { 052 return INFO_LICENSE_PANEL_TITLE.get(); 053 } 054 055 @Override 056 protected LocalizableMessage getInstructions() 057 { 058 return null; 059 } 060 061 private JCheckBox acceptCheck; 062 063 @Override 064 protected Component createInputPanel() 065 { 066 // No input in this panel 067 JPanel panel = new JPanel(new GridBagLayout()); 068 panel.setOpaque(false); 069 070 GridBagConstraints gbc = new GridBagConstraints(); 071 072 gbc.insets = UIFactory.getEmptyInsets(); 073 gbc.anchor = GridBagConstraints.NORTHWEST; 074 gbc.gridwidth = GridBagConstraints.REMAINDER; 075 gbc.weightx = 1.0; 076 gbc.fill = GridBagConstraints.HORIZONTAL; 077 078 JLabel l = 079 UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, 080 INFO_LICENSE_DETAILS_LABEL.get(), 081 UIFactory.TextStyle.SECONDARY_FIELD_VALID); 082 083 gbc.insets = UIFactory.getEmptyInsets(); 084 gbc.insets.bottom = 3; 085 panel.add(l, gbc); 086 087 JTextArea detailsTextArea = new JTextArea(10, 50); 088 detailsTextArea.setBackground( 089 UIFactory.CURRENT_STEP_PANEL_BACKGROUND); 090 detailsTextArea.setFont(UIFactory.TEXTFIELD_FONT); 091 detailsTextArea.setText(LicenseFile.getText()); 092 093 gbc.insets = UIFactory.getEmptyInsets(); 094 gbc.fill = GridBagConstraints.BOTH; 095 gbc.weighty = 1.0; 096 panel.add(new JScrollPane(detailsTextArea), gbc); 097 098 acceptCheck = UIFactory.makeJCheckBox(INFO_LICENSE_CLICK_LABEL.get(), 099 null, 100 UIFactory.TextStyle.SECONDARY_FIELD_VALID); 101 acceptCheck.setOpaque(false); 102 acceptCheck.setSelected(false); 103 104 gbc.insets = UIFactory.getEmptyInsets(); 105 gbc.insets.top = UIFactory.TOP_INSET_RADIO_SUBORDINATE; 106 gbc.fill = GridBagConstraints.BOTH; 107 gbc.weighty = 0.0; 108 panel.add(acceptCheck, gbc); 109 110 addActionListeners(); 111 112 return panel; 113 } 114 115 @Override 116 protected boolean requiresScroll() 117 { 118 return false; 119 } 120 121 /** Adds the required action listeners to the fields. */ 122 private void addActionListeners() 123 { 124 final ActionListener l = new ActionListener() 125 { 126 @Override 127 public void actionPerformed(ActionEvent e) 128 { 129 // Enable or disable Next button as user clicks approval button 130 getQuickSetup().getDialog().setButtonEnabled( 131 ButtonName.NEXT, acceptCheck.isSelected()); 132 133 // Save approval status for navigation 134 LicenseFile.setApproval(acceptCheck.isSelected()); 135 } 136 }; 137 138 acceptCheck.addActionListener(l); 139 } 140}