From 6d120a9a3f9d4a23ca83c5f715e7923e1d4103d7 Mon Sep 17 00:00:00 2001
From: jcduff <jcduff@localhost>
Date: Mon, 22 Dec 2008 15:32:17 +0000
Subject: [PATCH] Implement support for click-thru license approval in quicksetup. A new panel will show up to present the license if the license file Legal/license_to_accept.txt exists in the layout. Otherwise, quicksetup will have the same behavior as before.
---
opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgradeWizardStep.java | 8 +
opends/src/messages/messages/quicksetup.properties | 8 +
opends/src/quicksetup/org/opends/quicksetup/WizardStep.java | 7 +
opends/src/quicksetup/org/opends/quicksetup/installer/ui/InstallLicensePanel.java | 170 ++++++++++++++++++++++++
opends/src/quicksetup/org/opends/quicksetup/ui/ButtonsPanel.java | 6
opends/src/quicksetup/org/opends/quicksetup/Step.java | 12 +
opends/src/quicksetup/org/opends/quicksetup/LicenseFile.java | 140 ++++++++++++++++++++
opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java | 10 +
8 files changed, 361 insertions(+), 0 deletions(-)
diff --git a/opends/src/messages/messages/quicksetup.properties b/opends/src/messages/messages/quicksetup.properties
index a88aa32..8cae824 100644
--- a/opends/src/messages/messages/quicksetup.properties
+++ b/opends/src/messages/messages/quicksetup.properties
@@ -1328,6 +1328,14 @@
href="https://www.opends.org/wiki/page/OverviewOfTheQuickSetupTool"> OpenDS \
documentation wiki</a>.
INFO_WELCOME_STEP=Welcome
+INFO_LICENSE_PANEL_OFFLINE_INSTRUCTIONS=Please read the following important \
+ information before continuing.
+INFO_LICENSE_PANEL_TITLE=License
+INFO_LICENSE_PANEL_WEBSTART_INSTRUCTIONS=bla bla
+INFO_LICENSE_STEP=License
+INFO_LICENSE_DETAILS_LABEL=Please read the following License Agreement.\n\
+ You must accept the terms of the agreement before continuing with the installation.
+INFO_LICENSE_CLICK_LABEL=Click to accept
INFO_CONFIRM_UNINSTALL_STEP=Uninstall Options
INFO_ZIP_FILES_DESCRIPTION=OpenDS Installation Package (.zip)
SEVERE_ERR_COULD_NOT_FIND_REPLICATIONID=Could not find a remote peer to \
diff --git a/opends/src/quicksetup/org/opends/quicksetup/LicenseFile.java b/opends/src/quicksetup/org/opends/quicksetup/LicenseFile.java
new file mode 100644
index 0000000..cbb388a
--- /dev/null
+++ b/opends/src/quicksetup/org/opends/quicksetup/LicenseFile.java
@@ -0,0 +1,140 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE
+ * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
+ * add the following below this CDDL HEADER, with the fields enclosed
+ * by brackets "[]" replaced with your own identifying information:
+ * Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ * Copyright 2006-2008 Sun Microsystems, Inc.
+ */
+
+package org.opends.quicksetup;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+/**
+ * Represents information about the license file.
+ */
+public class LicenseFile {
+
+
+ /**
+ * The File object related to the license file.
+ */
+ static private File licFile = null;
+
+ /**
+ * The license file approval state.
+ */
+ static private boolean approved = false;
+
+ /**
+ * Returns the license file name.
+ */
+ static private String getName()
+ {
+ String installRootFromSystem = System.getProperty("INSTALL_ROOT");
+
+ if (installRootFromSystem == null) {
+ installRootFromSystem = System.getenv("INSTALL_ROOT");
+ }
+
+ if (installRootFromSystem == null) {
+ installRootFromSystem = "";
+ }
+
+ return installRootFromSystem + "/Legal/license_to_accept.txt";
+ }
+
+ /**
+ * Returns the license file object.
+ */
+ static private File getFile()
+ {
+ if (licFile == null) {
+ licFile = new File(getName());
+ }
+
+ return licFile;
+ }
+
+
+ /**
+ * Checks if the license file exists.
+ * @return <CODE>true</CODE> a license file license_to_accept.txt
+ * exists in the Legal directory in the top level installation directory
+ * <CODE>false</CODE> otherwise.
+ */
+ static public boolean exists()
+ {
+ return getFile().exists();
+ }
+
+
+ /**
+ * Get the textual contents of the license file.
+ * @return the textual contents of the license file.
+ */
+ static public String getText()
+ {
+ FileReader reader;
+
+ try {
+ reader = new FileReader(getFile());
+ } catch(Exception e) {
+ return "";
+ }
+
+ int fileLen = (int) getFile().length();
+
+ char[] charArray = new char[fileLen];
+
+ try {
+ reader.read(charArray);
+ } catch(IOException ioe) {
+ System.out.println("Could not read license file");
+ }
+
+ return new String(charArray);
+ }
+
+
+ /**
+ * Get the license approval status.
+ * @return <CODE>true</CODE> if the license has been accepted by the user
+ * <CODE>false</CODE> otherwise.
+ */
+ static public boolean getApproval()
+ {
+ return approved;
+ }
+
+
+ /**
+ * Sets the license approval status.
+ * @param p_approved the license approval status
+ */
+ static public void setApproval(boolean p_approved)
+ {
+ approved = p_approved;
+ }
+}
diff --git a/opends/src/quicksetup/org/opends/quicksetup/Step.java b/opends/src/quicksetup/org/opends/quicksetup/Step.java
index 4f6208e..5767d54 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/Step.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/Step.java
@@ -44,6 +44,11 @@
WELCOME(INFO_WELCOME_STEP.get()),
/**
+ * License approval step for the installation.
+ */
+ LICENSE(INFO_LICENSE_STEP.get()),
+
+ /**
* Confirmation panel for the uninstallation.
*/
CONFIRM_UNINSTALL(INFO_CONFIRM_UNINSTALL_STEP.get()),
@@ -124,4 +129,11 @@
return this == FINISHED;
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isLicenseStep() {
+ return this == LICENSE;
+ }
+
}
diff --git a/opends/src/quicksetup/org/opends/quicksetup/WizardStep.java b/opends/src/quicksetup/org/opends/quicksetup/WizardStep.java
index 262b93c..6ed4f80 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/WizardStep.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/WizardStep.java
@@ -56,4 +56,11 @@
*/
boolean isFinishedStep();
+ /**
+ * Indicates whether this is the license approval step.
+ * @return <CODE>true</CODE> if this is the license approval step
+ * and <CODE>false</CODE> otherwise.
+ */
+ boolean isLicenseStep();
+
}
diff --git a/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java b/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
index 6dfe642..005aebe 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
@@ -63,6 +63,7 @@
import org.opends.quicksetup.ButtonName;
import org.opends.quicksetup.Constants;
import org.opends.quicksetup.Installation;
+import org.opends.quicksetup.LicenseFile;
import org.opends.quicksetup.ProgressStep;
import org.opends.quicksetup.QuickSetupLog;
import org.opends.quicksetup.ReturnCode;
@@ -87,6 +88,7 @@
import org.opends.quicksetup.installer.ui.GlobalAdministratorPanel;
import org.opends.quicksetup.installer.ui.InstallReviewPanel;
import org.opends.quicksetup.installer.ui.InstallWelcomePanel;
+import org.opends.quicksetup.installer.ui.InstallLicensePanel;
import org.opends.quicksetup.installer.ui.RemoteReplicationPortsPanel;
import org.opends.quicksetup.installer.ui.ServerSettingsPanel;
import org.opends.quicksetup.installer.ui.SuffixesToReplicatePanel;
@@ -192,6 +194,9 @@
*/
public Installer() {
lstSteps.add(WELCOME);
+ if (LicenseFile.exists()) {
+ lstSteps.add(LICENSE);
+ }
lstSteps.add(SERVER_SETTINGS);
lstSteps.add(REPLICATION_OPTIONS);
lstSteps.add(CREATE_GLOBAL_ADMINISTRATOR);
@@ -511,6 +516,8 @@
QuickSetupStepPanel p = null;
if (step == WELCOME) {
p = new InstallWelcomePanel(this);
+ } else if (step == LICENSE) {
+ p = new InstallLicensePanel(this);
} else if (step == SERVER_SETTINGS) {
p = new ServerSettingsPanel(this);
} else if (step == REPLICATION_OPTIONS) {
@@ -716,6 +723,9 @@
{
LinkedHashSet<WizardStep> orderedSteps = new LinkedHashSet<WizardStep>();
orderedSteps.add(WELCOME);
+ if (lstSteps.contains(LICENSE)) {
+ orderedSteps.add(LICENSE);
+ }
orderedSteps.add(SERVER_SETTINGS);
orderedSteps.add(REPLICATION_OPTIONS);
orderedSteps.add(CREATE_GLOBAL_ADMINISTRATOR);
diff --git a/opends/src/quicksetup/org/opends/quicksetup/installer/ui/InstallLicensePanel.java b/opends/src/quicksetup/org/opends/quicksetup/installer/ui/InstallLicensePanel.java
new file mode 100644
index 0000000..5f939bc
--- /dev/null
+++ b/opends/src/quicksetup/org/opends/quicksetup/installer/ui/InstallLicensePanel.java
@@ -0,0 +1,170 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE
+ * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
+ * add the following below this CDDL HEADER, with the fields enclosed
+ * by brackets "[]" replaced with your own identifying information:
+ * Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ * Copyright 2006-2008 Sun Microsystems, Inc.
+ */
+
+package org.opends.quicksetup.installer.ui;
+
+import org.opends.messages.Message;
+import static org.opends.messages.QuickSetupMessages.*;
+
+import java.awt.Component;
+import java.awt.*;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+import javax.swing.*;
+
+import org.opends.quicksetup.ui.GuiApplication;
+import org.opends.quicksetup.ui.QuickSetupStepPanel;
+import org.opends.quicksetup.ui.UIFactory;
+import org.opends.quicksetup.util.Utils;
+import org.opends.quicksetup.Installation;
+import org.opends.quicksetup.LicenseFile;
+import org.opends.quicksetup.ButtonName;
+
+/**
+ * This panel is used to show a welcome message.
+ *
+ */
+public class InstallLicensePanel extends QuickSetupStepPanel
+{
+ private static final long serialVersionUID = 6209217138897900860L;
+
+ /**
+ * Default constructor.
+ * @param app Application this panel represents
+ */
+ public InstallLicensePanel(GuiApplication app)
+ {
+ super(app);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Message getTitle()
+ {
+ return INFO_LICENSE_PANEL_TITLE.get();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Message getInstructions()
+ {
+ /*
+ * We can use org.opends.server.util.DynamicConstants without problems as it
+ * has been added to quicksetup.jar during build time.
+ */
+ Message message;
+ if (Utils.isWebStart())
+ {
+ String cmd = Utils.isWindows()? Installation.WINDOWS_SETUP_FILE_NAME:
+ Installation.UNIX_SETUP_FILE_NAME;
+ message = INFO_LICENSE_PANEL_WEBSTART_INSTRUCTIONS.get();
+ }
+ else
+ {
+ message = INFO_LICENSE_PANEL_OFFLINE_INSTRUCTIONS.get();
+ }
+ return message;
+ }
+
+ private TextArea detailsTextArea;
+ private JCheckBox acceptCheck;
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Component createInputPanel()
+ {
+ // No input in this panel
+ JPanel panel = new JPanel(new GridBagLayout());
+ panel.setOpaque(false);
+
+ GridBagConstraints gbc = new GridBagConstraints();
+
+ gbc.insets = UIFactory.getEmptyInsets();
+ gbc.anchor = GridBagConstraints.NORTHWEST;
+ gbc.gridwidth = GridBagConstraints.REMAINDER;
+ gbc.weightx = 1.0;
+ gbc.fill = GridBagConstraints.HORIZONTAL;
+
+ JLabel l =
+ UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
+ INFO_LICENSE_DETAILS_LABEL.get(),
+ UIFactory.TextStyle.SECONDARY_FIELD_VALID);
+
+ gbc.insets = UIFactory.getEmptyInsets();
+ panel.add(l, gbc);
+
+ detailsTextArea = new TextArea();
+ detailsTextArea.setBackground(
+ UIFactory.CURRENT_STEP_PANEL_BACKGROUND);
+
+ detailsTextArea.setText(LicenseFile.getText());
+
+ gbc.insets = UIFactory.getEmptyInsets();
+ gbc.fill = GridBagConstraints.BOTH;
+ gbc.weighty = 1.0;
+ panel.add(detailsTextArea, gbc);
+
+ acceptCheck = UIFactory.makeJCheckBox(INFO_LICENSE_CLICK_LABEL.get(),
+ null,
+ UIFactory.TextStyle.SECONDARY_FIELD_VALID);
+ acceptCheck.setOpaque(false);
+ acceptCheck.setSelected(false);
+
+ gbc.insets = UIFactory.getEmptyInsets();
+ gbc.fill = GridBagConstraints.BOTH;
+ gbc.weighty = 0.0;
+ panel.add(acceptCheck, gbc);
+
+ addActionListeners();
+
+ return panel;
+ }
+
+ /**
+ * Adds the required action listeners to the fields.
+ */
+ private void addActionListeners()
+ {
+ final ActionListener l = new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ // Enable or disable Next button as user clicks approval button
+ getQuickSetup().getDialog().setButtonEnabled(
+ ButtonName.NEXT, acceptCheck.isSelected());
+
+ // Save approval status for navigation
+ LicenseFile.setApproval(acceptCheck.isSelected());
+ }
+ };
+
+ acceptCheck.addActionListener(l);
+ }
+}
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/ButtonsPanel.java b/opends/src/quicksetup/org/opends/quicksetup/ui/ButtonsPanel.java
index 36935b0..5cec29a 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/ButtonsPanel.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/ButtonsPanel.java
@@ -32,6 +32,7 @@
import org.opends.quicksetup.ButtonName;
import org.opends.quicksetup.WizardStep;
+import org.opends.quicksetup.LicenseFile;
import org.opends.quicksetup.event.ButtonActionListener;
import org.opends.quicksetup.event.ButtonEvent;
@@ -121,6 +122,11 @@
// is only enabled once progress has finished or cancelled.
closeButton.setVisible(step.isProgressStep() || step.isFinishedStep());
closeButton.setEnabled(application.getCurrentProgressStep().isLast());
+
+ // The next button is always enabled in all steps except the license step.
+ // In that step, the next button will be enabled only if the user has
+ // approved the license
+ nextButton.setEnabled(!step.isLicenseStep() || LicenseFile.getApproval());
}
/**
diff --git a/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgradeWizardStep.java b/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgradeWizardStep.java
index 359b32a..a8d9874 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgradeWizardStep.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgradeWizardStep.java
@@ -82,6 +82,14 @@
}
/**
+ * {@inheritDoc}
+ */
+ public boolean isLicenseStep() {
+ // Irrelevant here
+ return false;
+ }
+
+ /**
* Returns an String representation of this object.
* @return an String representation of this object. This method is
* overwritten in order to be able to use this objects as keys in Maps and
--
Gitblit v1.10.0