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-2010 Sun Microsystems, Inc.
015 * Portions Copyright 2015-2016 ForgeRock AS.
016 */
017package org.opends.quicksetup.ui;
018
019import javax.swing.*;
020import java.awt.*;
021
022/**
023 * Abstract class for rendering a review panel with fields and value
024 * that the user can use to confirm an application's operation.
025 */
026public abstract class ReviewPanel extends QuickSetupStepPanel {
027
028  private static final long serialVersionUID = 509534079919269557L;
029
030  /**
031   * Creates an instance.
032   * @param application GuiApplication this panel represents
033   */
034  public ReviewPanel(GuiApplication application) {
035    super(application);
036  }
037
038  /**
039   * Creates the panel containing field names and values.
040   * @return JPanel containing fields and values
041   */
042  protected abstract JPanel createFieldsPanel();
043
044  @Override
045  protected Component createInputPanel()
046  {
047    JPanel panel = UIFactory.makeJPanel();
048    panel.setLayout(new GridBagLayout());
049
050    GridBagConstraints gbc = new GridBagConstraints();
051
052    gbc.insets = UIFactory.getEmptyInsets();
053    gbc.gridwidth = GridBagConstraints.REMAINDER;
054    gbc.weightx = 1.0;
055    gbc.fill = GridBagConstraints.HORIZONTAL;
056    panel.add(createFieldsPanel(), gbc);
057
058    addVerticalGlue(panel);
059
060    JComponent chk = getBottomComponent();
061    if (chk != null) {
062      gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
063      gbc.weighty = 0.0;
064      gbc.fill = GridBagConstraints.HORIZONTAL;
065      panel.add(chk, gbc);
066    }
067
068    return panel;
069  }
070
071  /**
072   * Returns the component that will placed at the bottom of the panel.
073   * In the case of the installer and the uninstaller this is basically the
074   * start server check box.
075   * If it does not exist creates the component.
076   * @return the component that will placed at the bottom of the panel.
077   */
078  protected abstract JComponent getBottomComponent();
079}