This commit introduces preliminary versions of the upgrader tool's GUI wizard panels. Effort has been made to make the panels conform to the design at
http://bde.central/projects/opends/www/public/docs/ui-docs/specs/updater.html
As of now the panels are pure presentation as they do not display/edit any real data.
This commit also introduces a number of refactorings of the quick setup GUI wizard classes:
- Made createLayout() a private method that is called during initialize() rather than the constuctor of each child application. In general I don't like constructors that do lots of work beyond initializing variables since you can override behavior. I've also added GuiApplication as a parameter to QuickSetupPanel since it can provide panels with any state information that the panel need to present.
- Moved QuickSetup to the ui package since its purpose is representing quicksetup GUI applications.
- Made ReviewPanel abstract so that other applications could share the layout code.
7 files added
3 files renamed
24 files modified
| | |
| | | # Configure the appropriate CLASSPATH. |
| | | # Unlike BuildExtractor, the Upgrader uses |
| | | # the newly extracted build's jars. |
| | | CLASSPATH=${INSTANCE_ROOT}/tmp/upgrade/classes |
| | | for JAR in ${INSTANCE_ROOT}/tmp/upgrade/lib/*.jar |
| | | do |
| | | CLASSPATH=${CLASSPATH}:${JAR} |
| | | CLASSPATH=${JAR}:${CLASSPATH} |
| | | done |
| | | export CLASSPATH |
| | | echo ${CLASSPATH} |
| | | # Launch the upgrade process. |
| | | "${JAVA_BIN}" org.opends.quicksetup.upgrader.UpgradeLauncher "${@}" |
| | | |
| | |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.quicksetup.util.ProgressMessageFormatter; |
| | | import org.opends.quicksetup.i18n.ResourceProvider; |
| | | import org.opends.quicksetup.ui.GuiApplication; |
| | | |
| | | import java.io.PrintStream; |
| | | import java.io.ByteArrayOutputStream; |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns whether the installer has finished or not. |
| | | * @return <CODE>true</CODE> if the install is finished or <CODE>false |
| | | * </CODE> if not. |
| | | */ |
| | | public boolean isFinished() |
| | | { |
| | | return getCurrentProgressStep().isLast(); |
| | | } |
| | | |
| | | /** |
| | | * This class is used to notify the ProgressUpdateListeners of events |
| | | * that are written to the standard error. It is used in WebStartInstaller |
| | | * and in OfflineInstaller. These classes just create a ErrorPrintStream and |
| New file |
| | |
| | | /* |
| | | * 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 |
| | | * |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.quicksetup; |
| | | |
| | | /** |
| | | * This class is just used to specify which are the default values that will be |
| | | * proposed to the user in the Data Options panel of the Installation wizard. |
| | | * |
| | | */ |
| | | class DefaultDataOptions extends DataOptions |
| | | { |
| | | /** |
| | | * Default constructor. |
| | | * |
| | | */ |
| | | public DefaultDataOptions() |
| | | { |
| | | super(Type.CREATE_BASE_ENTRY, "dc=example,dc=com"); |
| | | } |
| | | |
| | | /** |
| | | * Get the number of entries that will be automatically generated. |
| | | * |
| | | * @return the number of entries that will be automatically generated. |
| | | */ |
| | | public int getNumberEntries() |
| | | { |
| | | return 2000; |
| | | } |
| | | |
| | | } |
| | |
| | | { |
| | | try |
| | | { |
| | | quickSetupClass = Class.forName("org.opends.quicksetup.QuickSetup"); |
| | | quickSetupClass = Class.forName("org.opends.quicksetup.ui.QuickSetup"); |
| | | quickSetup = quickSetupClass.newInstance(); |
| | | quickSetupClass.getMethod("initialize", new Class[] |
| | | { String[].class }).invoke(quickSetup, new Object[] |
| | |
| | | |
| | | /** |
| | | * This method displays the QuickSetup dialog. |
| | | * @see QuickSetup#display |
| | | * @see org.opends.quicksetup.ui.QuickSetup#display |
| | | * This method assumes that is being called outside the event thread. |
| | | * This method can be overwritten by subclasses to construct other objects |
| | | * different than the Quick Setup. |
| | |
| | | * Welcome step for the installation. |
| | | */ |
| | | WELCOME("welcome-step"), |
| | | |
| | | /** |
| | | * Confirmation panel for the uninstallation. |
| | | */ |
| | | CONFIRM_UNINSTALL("confirm-uninstall-step"), |
| | | |
| | | /** |
| | | * Server Settings step (path, port, etc.). |
| | | */ |
| | | SERVER_SETTINGS("server-settings-step"), |
| | | |
| | | /** |
| | | * Data Options panel (suffix dn, LDIF path, etc.). |
| | | */ |
| | | DATA_OPTIONS("data-options-step"), |
| | | |
| | | /** |
| | | * Review panel for the install. |
| | | */ |
| | | REVIEW("review-step"), |
| | | |
| | | /** |
| | | * Progress panel. |
| | | */ |
| | | PROGRESS("progress-step"), |
| | | /** |
| | | * Confirmation panel for the uninstallation. |
| | | */ |
| | | CONFIRM_UNINSTALL("confirm-uninstall-step"); |
| | | PROGRESS("progress-step"); |
| | | |
| | | private String msgKey; |
| | | |
| | |
| | | import org.opends.quicksetup.ui.*; |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.quicksetup.*; |
| | | import org.opends.quicksetup.installer.ui.InstallReviewPanel; |
| | | import org.opends.server.util.SetupUtils; |
| | | |
| | | import javax.swing.*; |
| | |
| | | public QuickSetupStepPanel createWizardStepPanel(WizardStep step) { |
| | | QuickSetupStepPanel p = null; |
| | | if (step == WELCOME) { |
| | | p = new InstallWelcomePanel(); |
| | | p = new InstallWelcomePanel(this); |
| | | } else if (step == SERVER_SETTINGS) { |
| | | p = new ServerSettingsPanel(getUserData()); |
| | | p = new ServerSettingsPanel(this); |
| | | } else if (step == DATA_OPTIONS) { |
| | | p = new DataOptionsPanel(getUserData()); |
| | | p = new DataOptionsPanel(this); |
| | | } else if (step == REVIEW) { |
| | | p = new ReviewPanel(getUserData()); |
| | | p = new InstallReviewPanel(this); |
| | | } else if (step == PROGRESS) { |
| | | p = new ProgressPanel(); |
| | | p = new ProgressPanel(this); |
| | | } |
| | | return p; |
| | | } |
| | |
| | | * valid. |
| | | * |
| | | */ |
| | | protected void updateUserData(WizardStep cStep, QuickSetup qs) |
| | | public void updateUserData(WizardStep cStep, QuickSetup qs) |
| | | throws UserDataException |
| | | { |
| | | if (cStep == SERVER_SETTINGS) { |
| New file |
| | |
| | | /* |
| | | * 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 |
| | | * |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.quicksetup.installer.ui; |
| | | |
| | | import org.opends.quicksetup.DataOptions; |
| | | import org.opends.quicksetup.UserData; |
| | | import org.opends.quicksetup.ui.*; |
| | | |
| | | import javax.swing.*; |
| | | import javax.swing.text.JTextComponent; |
| | | import java.awt.*; |
| | | import java.util.HashMap; |
| | | |
| | | /** |
| | | * This is the panel that contains the Review Panel. |
| | | * |
| | | */ |
| | | public class InstallReviewPanel extends ReviewPanel { |
| | | |
| | | private static final long serialVersionUID = -7356174829193265699L; |
| | | |
| | | private boolean displayServerLocation; |
| | | |
| | | private HashMap<FieldName, JLabel> hmLabels = |
| | | new HashMap<FieldName, JLabel>(); |
| | | |
| | | private HashMap<FieldName, JTextComponent> hmFields = |
| | | new HashMap<FieldName, JTextComponent>(); |
| | | |
| | | /** |
| | | * Constructor of the panel. |
| | | * @param application Application represented by this panel |
| | | * the fields of the panel. |
| | | */ |
| | | public InstallReviewPanel(GuiApplication application) |
| | | { |
| | | super(application); |
| | | this.displayServerLocation = isWebStart(); |
| | | populateLabelAndFieldsMap(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void beginDisplay(UserData userData) |
| | | { |
| | | if (displayServerLocation) |
| | | { |
| | | setFieldValue(FieldName.SERVER_LOCATION, userData.getServerLocation()); |
| | | } |
| | | setFieldValue(FieldName.SERVER_PORT, String.valueOf(userData |
| | | .getServerPort())); |
| | | setFieldValue(FieldName.DIRECTORY_MANAGER_DN, userData |
| | | .getDirectoryManagerDn()); |
| | | setFieldValue(FieldName.DIRECTORY_BASE_DN, userData.getDataOptions() |
| | | .getBaseDn()); |
| | | setFieldValue(FieldName.DATA_OPTIONS, getDisplayString(userData |
| | | .getDataOptions())); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Object getFieldValue(FieldName fieldName) |
| | | { |
| | | Object value = null; |
| | | if (fieldName == FieldName.SERVER_START) |
| | | { |
| | | value = getCheckBox().isSelected(); |
| | | } |
| | | return value; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected String getInstructions() |
| | | { |
| | | return getMsg("review-panel-instructions"); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected String getTitle() |
| | | { |
| | | return getMsg("review-panel-title"); |
| | | } |
| | | |
| | | /** |
| | | * Create the components and populate the Maps. |
| | | */ |
| | | private void populateLabelAndFieldsMap() |
| | | { |
| | | HashMap<FieldName, LabelFieldDescriptor> hm = |
| | | new HashMap<FieldName, LabelFieldDescriptor>(); |
| | | |
| | | if (displayServerLocation) |
| | | { |
| | | hm.put(FieldName.SERVER_LOCATION, new LabelFieldDescriptor( |
| | | getMsg("server-location-label"), getMsg("server-port-tooltip"), |
| | | LabelFieldDescriptor.FieldType.READ_ONLY, |
| | | LabelFieldDescriptor.LabelType.PRIMARY, 0)); |
| | | } |
| | | |
| | | hm.put(FieldName.SERVER_PORT, new LabelFieldDescriptor( |
| | | getMsg("server-port-label"), getMsg("server-port-tooltip"), |
| | | LabelFieldDescriptor.FieldType.READ_ONLY, |
| | | LabelFieldDescriptor.LabelType.PRIMARY, 0)); |
| | | |
| | | hm.put(FieldName.DIRECTORY_MANAGER_DN, new LabelFieldDescriptor( |
| | | getMsg("server-directory-manager-dn-label"), |
| | | getMsg("server-directory-manager-dn-tooltip"), |
| | | LabelFieldDescriptor.FieldType.READ_ONLY, |
| | | LabelFieldDescriptor.LabelType.PRIMARY, 0)); |
| | | |
| | | hm.put(FieldName.DIRECTORY_BASE_DN, new LabelFieldDescriptor( |
| | | getMsg("base-dn-label"), getMsg("base-dn-tooltip"), |
| | | LabelFieldDescriptor.FieldType.READ_ONLY, |
| | | LabelFieldDescriptor.LabelType.PRIMARY, 0)); |
| | | |
| | | hm.put(FieldName.DATA_OPTIONS, new LabelFieldDescriptor( |
| | | getMsg("directory-data-label"), null, |
| | | LabelFieldDescriptor.FieldType.READ_ONLY, |
| | | LabelFieldDescriptor.LabelType.PRIMARY, 0)); |
| | | for (FieldName fieldName : hm.keySet()) |
| | | { |
| | | LabelFieldDescriptor desc = hm.get(fieldName); |
| | | |
| | | JTextComponent field = UIFactory.makeJTextComponent(desc, null); |
| | | field.setOpaque(false); |
| | | JLabel label = makeJLabel(desc); |
| | | |
| | | hmFields.put(fieldName, field); |
| | | label.setLabelFor(field); |
| | | |
| | | hmLabels.put(fieldName, label); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns the label associated with the given field name. |
| | | * @param fieldName the field name for which we want to retrieve the JLabel. |
| | | * @return the label associated with the given field name. |
| | | */ |
| | | private JLabel getLabel(FieldName fieldName) |
| | | { |
| | | return hmLabels.get(fieldName); |
| | | } |
| | | |
| | | /** |
| | | * Returns the JTextComponent associated with the given field name. |
| | | * @param fieldName the field name for which we want to retrieve the |
| | | * JTextComponent. |
| | | * @return the JTextComponent associated with the given field name. |
| | | */ |
| | | private JTextComponent getField(FieldName fieldName) |
| | | { |
| | | return hmFields.get(fieldName); |
| | | } |
| | | |
| | | /** |
| | | * Updates the JTextComponent associated with a FieldName with a text value. |
| | | * @param fieldName the field name of the JTextComponent that we want to |
| | | * update. |
| | | * @param value the value to be set. |
| | | */ |
| | | private void setFieldValue(FieldName fieldName, String value) |
| | | { |
| | | getField(fieldName).setText(value); |
| | | } |
| | | |
| | | /** |
| | | * Returns the localized string describing the DataOptions chosen by the user. |
| | | * @param options the DataOptions of the user. |
| | | * @return the localized string describing the DataOptions chosen by the user. |
| | | */ |
| | | private String getDisplayString(DataOptions options) |
| | | { |
| | | String msg; |
| | | |
| | | switch (options.getType()) |
| | | { |
| | | case CREATE_BASE_ENTRY: |
| | | msg = getMsg("review-create-base-entry-label", new String[] |
| | | { options.getBaseDn() }); |
| | | |
| | | break; |
| | | |
| | | case LEAVE_DATABASE_EMPTY: |
| | | msg = getMsg("review-leave-database-empty-label"); |
| | | break; |
| | | |
| | | case IMPORT_FROM_LDIF_FILE: |
| | | msg = getMsg("review-import-ldif", new String[] |
| | | { options.getLDIFPath() }); |
| | | break; |
| | | |
| | | case IMPORT_AUTOMATICALLY_GENERATED_DATA: |
| | | msg = getMsg("review-import-automatically-generated", new String[] |
| | | { String.valueOf(options.getNumberEntries()) }); |
| | | break; |
| | | |
| | | default: |
| | | throw new IllegalArgumentException("Unknow type: " + options.getType()); |
| | | |
| | | } |
| | | |
| | | return msg; |
| | | } |
| | | |
| | | /** |
| | | * Returns and creates the fields panel. |
| | | * @return the fields panel. |
| | | */ |
| | | protected JPanel createFieldsPanel() |
| | | { |
| | | JPanel panel = new JPanel(new GridBagLayout()); |
| | | panel.setOpaque(false); |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | |
| | | FieldName[] fieldNames; |
| | | if (displayServerLocation) |
| | | { |
| | | fieldNames = |
| | | new FieldName[] |
| | | { FieldName.SERVER_LOCATION, FieldName.SERVER_PORT, |
| | | FieldName.DIRECTORY_MANAGER_DN, |
| | | FieldName.DIRECTORY_BASE_DN, |
| | | FieldName.DATA_OPTIONS }; |
| | | } else |
| | | { |
| | | fieldNames = |
| | | new FieldName[] |
| | | { FieldName.SERVER_PORT, FieldName.DIRECTORY_MANAGER_DN, |
| | | FieldName.DIRECTORY_BASE_DN, FieldName.DATA_OPTIONS }; |
| | | } |
| | | |
| | | for (int i = 0; i < fieldNames.length; i++) |
| | | { |
| | | gbc.gridwidth = GridBagConstraints.RELATIVE; |
| | | gbc.weightx = 0.0; |
| | | if (i > 0) |
| | | { |
| | | gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD; |
| | | } else |
| | | { |
| | | gbc.insets.top = 0; |
| | | } |
| | | gbc.insets.left = 0; |
| | | gbc.anchor = GridBagConstraints.NORTHWEST; |
| | | panel.add(getLabel(fieldNames[i]), gbc); |
| | | |
| | | JPanel auxPanel = new JPanel(new GridBagLayout()); |
| | | auxPanel.setOpaque(false); |
| | | gbc.weightx = 1.0; |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | if (i > 0) |
| | | { |
| | | gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD; |
| | | } else |
| | | { |
| | | gbc.insets.top = 0; |
| | | } |
| | | gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD; |
| | | |
| | | gbc.gridwidth = GridBagConstraints.REMAINDER; |
| | | panel.add(auxPanel, gbc); |
| | | |
| | | gbc.insets = UIFactory.getEmptyInsets(); |
| | | gbc.gridwidth = GridBagConstraints.REMAINDER; |
| | | gbc.weightx = 1.0; |
| | | auxPanel.add(getField(fieldNames[i]), gbc); |
| | | } |
| | | |
| | | return panel; |
| | | } |
| | | } |
| | |
| | | # |
| | | upgrade-launcher-description=This utility may be used to upgrade the Directory \ |
| | | Server to a newer version. |
| | | upgrade-launcher-usage=This utility may be used to upgrade the \ |
| | | Directory Server to a newer version.\n\ |
| | | Usage: {0} {options}\n where {options} include:\n\ |
| | | --cli\n\ Specifies to use the command line upgrade. If not specified the \ |
| | | graphical\n\ interface will be launched.\n\ |
| | | -H, --help\n Displays usage information for this program.\n\n\ |
| | | The following options will only be taken into account if the option --cli \n\ |
| | | (command line) is specified\n\ |
| | | -s, --silentUpgrade\n Perform a silent upgrade. |
| | | upgrade-launcher-usage=This utility may be used to upgrade the Directory Server \ |
| | | to a newer version.\nUsage: {0} {options} where {options} \ |
| | | include:\n\n -f, --file\n Specifies an existing OpenDS package (.zip) \ |
| | | file to which the\n current build will be upgraded.\n\n -c, --cli\n \ |
| | | Use the command line upgrade. If not specified the graphical\n interface \ |
| | | will be launched.\n |
| | | upgrade-launcher-launching-gui=Launching graphical upgrade... |
| | | upgrade-launcher-launching-cli=Launching command line upgrade... |
| | | upgrade-launcher-gui-launched-failed=\n\nThe graphical upgrade launch \ |
| | |
| | | (schema checking disabled): {0} |
| | | upgrade-mod=Processed server modifications: {0} |
| | | upgrade-mod-ignore=Attribute or value already exists: {0} |
| | | |
| | | # |
| | | # Upgrader Panels |
| | | # |
| | | # |
| | | # Welcome Panel specific labels |
| | | # |
| | | upgrade-welcome-panel-title=Welcome |
| | | # The following line contains some HTML tags. translators should respect them. |
| | | # Concerning the URL, depending on how works the product page translators |
| | | # have to modify it or not: if the server uses the locale of the browser to display |
| | | # a language there is no translation to be done but if we have specific URL for |
| | | # each language the URL must be localized. |
| | | upgrade-welcome-panel-offline-instructions=The OpenDS Upgrade tool will upgrade \ |
| | | an existing build in place.<br><br> \ |
| | | Additional information on this tool is available in the <a href="https://opends.dev.java.net/public/docs/index.html"> \ |
| | | Documentation Depot</a> section of OpenDS project web site. |
| | | upgrade-welcome-panel-webstart-instructions=The OpenDS Upgrade tool will upgrade \ |
| | | an existing build in place.<br><br>You can also use this tool to set up a build you have \ |
| | | downloaded manually. To run Upgrade in this case, use the {0} command at \ |
| | | the top level of the OpenDS directory.<br><br> \ |
| | | Additional information on this tool is available in the <a href="https://opends.dev.java.net/public/docs/index.html"> \ |
| | | Documentation Depot</a> section of OpenDS project web site.<br><br> |
| | | upgrade-location-label=Server to Upgrade: |
| | | upgrade-location-tooltip=File system location of the build that will be upgraded |
| | | upgrade-build-id-label=Build Version: |
| | | upgrade-build-id-tooltip=The ID of the build version installed in the above location |
| | | |
| | | # |
| | | # Upgrader Choose Version Panel |
| | | # |
| | | upgrade-choose-version-panel-title=Choose New Version |
| | | upgrade-choose-version-panel-instructions=Choose a new version or reference \ |
| | | build to use for the upgrading. |
| | | upgrade-choose-version-remote-label=Choose New Version from opends.dev.java.net |
| | | upgrade-choose-version-remote-tooltip=Download and upgrade to a build publicly \ |
| | | available on the OpenDS website. |
| | | upgrade-choose-version-remote-weekly=Weekly Builds |
| | | upgrade-choose-version-remote-nightly=Nightly Builds |
| | | upgrade-choose-version-local-label=Upgrade Based on Downloaded Weekly Build (.zip) |
| | | upgrade-choose-version-local-tooltip=Upgrade to a build whose .zip file you have\ |
| | | already downloaded. |
| | | upgrade-choose-version-local-path=Path: |
| | | |
| | | upgrade-review-panel-title=Review |
| | | upgrade-review-panel-instructions=Review your settings and click Finish if they \ |
| | | are correct. |
| | | upgrade-review-panel-server-label=Server to Upgrade: |
| | | upgrade-review-panel-server-tooltip=File system location of the build that will be upgraded |
| | | upgrade-review-panel-old-version-label=Old Version: |
| | | upgrade-review-panel-old-version-tooltip=The current version of the server |
| | | upgrade-review-panel-new-version-label=New Version: |
| | | upgrade-review-panel-new-version-tooltip=The target version of the server |
| | | upgrade-review-panel-start-server=Start Server when the Upgrade has Completed |
| | |
| | | |
| | | package org.opends.quicksetup.ui; |
| | | |
| | | import java.awt.GridBagConstraints; |
| | | import java.awt.GridBagLayout; |
| | | import java.awt.event.ActionEvent; |
| | | import java.awt.event.ActionListener; |
| | | |
| | | import java.util.HashSet; |
| | | |
| | | import javax.swing.Box; |
| | | import javax.swing.JButton; |
| | | import javax.swing.JPanel; |
| | | |
| | | import org.opends.quicksetup.ButtonName; |
| | | import org.opends.quicksetup.WizardStep; |
| | | import org.opends.quicksetup.GuiApplication; |
| | | import org.opends.quicksetup.uninstaller.Uninstaller; |
| | | import org.opends.quicksetup.installer.Installer; |
| | | import org.opends.quicksetup.event.ButtonActionListener; |
| | | import org.opends.quicksetup.event.ButtonEvent; |
| | | import org.opends.quicksetup.installer.Installer; |
| | | import org.opends.quicksetup.uninstaller.Uninstaller; |
| | | |
| | | import javax.swing.*; |
| | | import java.awt.*; |
| | | import java.awt.event.ActionEvent; |
| | | import java.awt.event.ActionListener; |
| | | import java.util.HashSet; |
| | | |
| | | /** |
| | | * This class contains the buttons in the bottom of the Install/Uninstall |
| | |
| | | |
| | | private JButton cancelButton; |
| | | |
| | | private GuiApplication application; |
| | | |
| | | /** |
| | | * Default constructor. |
| | | * @param application Application running in QuickSetup |
| | |
| | | */ |
| | | public ButtonsPanel(GuiApplication application) |
| | | { |
| | | this.application = application; |
| | | super(application); |
| | | createButtons(); |
| | | layoutButtons(); |
| | | } |
| | |
| | | */ |
| | | public void setDisplayedStep(WizardStep step) |
| | | { |
| | | GuiApplication application = getApplication(); |
| | | previousButton.setVisible(application.canGoBack(step)); |
| | | nextButton.setVisible(application.canGoForward(step)); |
| | | finishButton.setVisible(application.canFinish(step)); |
| | |
| | | public JButton getButton(ButtonName buttonName) |
| | | { |
| | | JButton b = null; |
| | | switch (buttonName) |
| | | { |
| | | if (buttonName != null) { |
| | | switch (buttonName) { |
| | | case NEXT: |
| | | b = nextButton; |
| | | break; |
| | |
| | | throw new IllegalArgumentException("Unknown button name: " + |
| | | buttonName); |
| | | } |
| | | } |
| | | |
| | | return b; |
| | | } |
| | |
| | | quitButton = |
| | | createButton("quit-button-label", tooltip, ButtonName.QUIT); |
| | | |
| | | GuiApplication application = getApplication(); |
| | | |
| | | tooltip = application.getCloseButtonToolTip(); |
| | | closeButton = createButton("close-button-label", tooltip, ButtonName.CLOSE); |
| | | |
| | |
| | | nextFinishPanel.add(nextButton, gbcAux); |
| | | |
| | | // TODO: remove this hack |
| | | if (application instanceof Installer) { |
| | | if (getApplication() instanceof Installer) { |
| | | nextFinishPanel.add(finishButton, gbcAux); |
| | | } |
| | | width = |
| | |
| | | gbc.insets.left = UIFactory.HORIZONTAL_INSET_BETWEEN_BUTTONS; |
| | | |
| | | // TODO: remove this hack |
| | | if (application instanceof Uninstaller) { |
| | | if (getApplication() instanceof Uninstaller) { |
| | | gbc.insets.right = UIFactory.HORIZONTAL_INSET_BETWEEN_BUTTONS; |
| | | add(finishButton, gbc); |
| | | gbc.insets.right = 0; |
| | |
| | | |
| | | package org.opends.quicksetup.ui; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | | import java.awt.GridBagLayout; |
| | | import org.opends.quicksetup.CurrentInstallStatus; |
| | | import org.opends.quicksetup.util.Utils; |
| | | |
| | | import javax.swing.*; |
| | | import javax.swing.border.EmptyBorder; |
| | | import java.awt.*; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.Set; |
| | | |
| | | import javax.swing.Box; |
| | | import javax.swing.DefaultListModel; |
| | | import javax.swing.JCheckBox; |
| | | import javax.swing.JList; |
| | | import javax.swing.JPanel; |
| | | import javax.swing.JScrollPane; |
| | | import javax.swing.border.EmptyBorder; |
| | | |
| | | import org.opends.quicksetup.CurrentInstallStatus; |
| | | import org.opends.quicksetup.installer.FieldName; |
| | | import org.opends.quicksetup.util.Utils; |
| | | |
| | | /** |
| | | * This is the panel displayed when the user is uninstalling Open DS. It is |
| | | * basically a panel with the text informing of the consequences of uninstalling |
| | |
| | | |
| | | /** |
| | | * The constructor of this class. |
| | | * @param application Application this panel represents |
| | | * @param installStatus the object describing the current installation status. |
| | | * |
| | | */ |
| | | public ConfirmUninstallPanel(CurrentInstallStatus installStatus) |
| | | public ConfirmUninstallPanel(GuiApplication application, |
| | | CurrentInstallStatus installStatus) |
| | | { |
| | | super(application); |
| | | this.installStatus = installStatus; |
| | | createLayout(); |
| | | } |
| | | |
| | | /** |
| | |
| | | import java.util.Set; |
| | | |
| | | import org.opends.quicksetup.event.ButtonActionListener; |
| | | import org.opends.quicksetup.installer.FieldName; |
| | | import org.opends.quicksetup.installer.Installer; |
| | | import org.opends.quicksetup.*; |
| | | |
| | |
| | | private HashMap<WizardStep, QuickSetupStepPanel> hmPanels = |
| | | new HashMap<WizardStep, QuickSetupStepPanel>(); |
| | | |
| | | private Application application; |
| | | |
| | | /** |
| | | * The constructor of this class. |
| | | * @param app Application used to create panels for populating the layout |
| | | */ |
| | | public CurrentStepPanel(GuiApplication app) |
| | | { |
| | | this.application = app; |
| | | super(app); |
| | | createLayout(app); |
| | | } |
| | | |
| | |
| | | for (WizardStep step : steps) { |
| | | QuickSetupStepPanel panel = app.createWizardStepPanel(step); |
| | | if (panel != null) { |
| | | panel.initialize(); |
| | | hmPanels.put(step, panel); |
| | | } |
| | | } |
| | |
| | | |
| | | // For aesthetical reasons we add a little bit of height |
| | | // TODO: remove this hack |
| | | if (application instanceof Installer) |
| | | if (getApplication() instanceof Installer) |
| | | { |
| | | minHeight += UIFactory.EXTRA_DIALOG_HEIGHT; |
| | | } |
| | |
| | | |
| | | import org.opends.quicksetup.event.BrowseActionListener; |
| | | import org.opends.quicksetup.DataOptions; |
| | | import org.opends.quicksetup.installer.FieldName; |
| | | import org.opends.quicksetup.UserData; |
| | | |
| | | /** |
| | |
| | | |
| | | /** |
| | | * Constructor of the panel. |
| | | * @param defaultUserData the default values that must be used to initialize |
| | | * @param application Application represented by this panel |
| | | * the fields of the panel. |
| | | */ |
| | | public DataOptionsPanel(UserData defaultUserData) |
| | | public DataOptionsPanel(GuiApplication application) |
| | | { |
| | | this.defaultUserData = defaultUserData; |
| | | super(application); |
| | | this.defaultUserData = application.getUserData(); |
| | | populateComponentMaps(); |
| | | addDocumentListeners(); |
| | | addFocusListeners(); |
| | | createLayout(); |
| | | } |
| | | |
| | | /** |
| | |
| | | private JPanel createBrowseButtonPanel(FieldName fieldName, |
| | | JButton browseButton) |
| | | { |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | |
| | | JPanel panel = new JPanel(new GridBagLayout()); |
| | | panel.setOpaque(false); |
| | | gbc.insets = UIFactory.getEmptyInsets(); |
| | | gbc.gridwidth = 4; |
| | | gbc.weightx = 0.0; |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | panel.add(getLabel(fieldName), gbc); |
| | | |
| | | gbc.insets.left = UIFactory.LEFT_INSET_SECONDARY_FIELD; |
| | | gbc.gridwidth--; |
| | | gbc.weightx = 0.1; |
| | | panel.add(getField(fieldName), gbc); |
| | | |
| | | gbc.insets.left = UIFactory.LEFT_INSET_BROWSE; |
| | | gbc.gridwidth = GridBagConstraints.RELATIVE; |
| | | panel.add(browseButton, gbc); |
| | | |
| | | gbc.weightx = 1.0; |
| | | gbc.gridwidth = GridBagConstraints.REMAINDER; |
| | | panel.add(Box.createHorizontalGlue(), gbc); |
| | | |
| | | return panel; |
| | | return Utilities.createBrowseButtonPanel( |
| | | getLabel(fieldName), |
| | | getField(fieldName), |
| | | browseButton); |
| | | } |
| | | |
| | | /** |
| | |
| | | LabelFieldDescriptor desc = hm.get(fieldName); |
| | | |
| | | String defaultValue = getDefaultStringValue(fieldName); |
| | | field = makeJTextComponent(desc, defaultValue); |
| | | field = UIFactory.makeJTextComponent(desc, defaultValue); |
| | | |
| | | hmFields.put(fieldName, field); |
| | | |
| | | JLabel l = makeJLabel(desc); |
| | | JLabel l = UIFactory.makeJLabel(desc); |
| | | |
| | | l.setLabelFor(field); |
| | | |
| File was renamed from opends/src/quicksetup/org/opends/quicksetup/installer/FieldName.java |
| | |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.quicksetup.installer; |
| | | package org.opends.quicksetup.ui; |
| | | |
| | | /** |
| | | * This is an enumeration used to identify the different fields that we have |
| | |
| | | * The value associated with this is a Set of String. |
| | | */ |
| | | EXTERNAL_LOG_FILES |
| | | |
| | | } |
| File was renamed from opends/src/quicksetup/org/opends/quicksetup/GuiApplication.java |
| | |
| | | * Portions Copyright 2007 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.quicksetup; |
| | | package org.opends.quicksetup.ui; |
| | | |
| | | import org.opends.quicksetup.ui.FramePanel; |
| | | import org.opends.quicksetup.ui.QuickSetupDialog; |
| | | import org.opends.quicksetup.ui.QuickSetupStepPanel; |
| | | import org.opends.quicksetup.*; |
| | | |
| | | import javax.swing.*; |
| | | import java.awt.event.WindowEvent; |
| | |
| | | abstract public String getFrameTitle(); |
| | | |
| | | /** |
| | | * Returns whether the installer has finished or not. |
| | | * @return <CODE>true</CODE> if the install is finished or <CODE>false |
| | | * </CODE> if not. |
| | | */ |
| | | public boolean isFinished() |
| | | { |
| | | return getCurrentProgressStep().isLast(); |
| | | } |
| | | |
| | | /** |
| | | * Returns the initial wizard step. |
| | | * @return Step representing the first step to show in the wizard |
| | | */ |
| | |
| | | * @param userData UserData representing the data specified by the user |
| | | * @param dlg QuickSetupDialog hosting the wizard |
| | | */ |
| | | protected void setDisplayedWizardStep(WizardStep step, |
| | | public void setDisplayedWizardStep(WizardStep step, |
| | | UserData userData, |
| | | QuickSetupDialog dlg) { |
| | | this.displayedStep = step; |
| | |
| | | * values found in QuickSetup. |
| | | * @param cStep current wizard step |
| | | * @param qs QuickSetup controller |
| | | * @throws UserDataException if there is a problem with the data |
| | | * @throws org.opends.quicksetup.UserDataException if there is a problem with |
| | | * the data |
| | | */ |
| | | abstract protected void updateUserData(WizardStep cStep, QuickSetup qs) |
| | | public abstract void updateUserData(WizardStep cStep, QuickSetup qs) |
| | | throws UserDataException; |
| | | |
| | | /** |
| | |
| | | |
| | | /** |
| | | * Default constructor. |
| | | * |
| | | * @param app Application this panel represents |
| | | */ |
| | | public InstallWelcomePanel() |
| | | public InstallWelcomePanel(GuiApplication app) |
| | | { |
| | | createLayout(); |
| | | super(app); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | /** |
| | | * ProgressPanel constructor. |
| | | * @param application Application this panel represents |
| | | */ |
| | | public ProgressPanel() |
| | | public ProgressPanel(GuiApplication application) |
| | | { |
| | | createLayout(); |
| | | super(application); |
| | | } |
| | | |
| | | /** |
| File was renamed from opends/src/quicksetup/org/opends/quicksetup/QuickSetup.java |
| | |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.quicksetup; |
| | | package org.opends.quicksetup.ui; |
| | | |
| | | import org.opends.quicksetup.event.ButtonActionListener; |
| | | import org.opends.quicksetup.event.ProgressUpdateListener; |
| | | import org.opends.quicksetup.event.ButtonEvent; |
| | | import org.opends.quicksetup.event.ProgressUpdateEvent; |
| | | import org.opends.quicksetup.event.ProgressUpdateListener; |
| | | import org.opends.quicksetup.*; |
| | | import org.opends.quicksetup.i18n.ResourceProvider; |
| | | import org.opends.quicksetup.installer.FieldName; |
| | | import org.opends.quicksetup.ui.QuickSetupDialog; |
| | | import org.opends.quicksetup.ui.UIFactory; |
| | | import org.opends.quicksetup.util.BackgroundTask; |
| | | import org.opends.quicksetup.util.ProgressMessageFormatter; |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.quicksetup.util.HtmlProgressMessageFormatter; |
| | | import org.opends.quicksetup.util.BackgroundTask; |
| | | import org.opends.quicksetup.util.Utils; |
| | | |
| | | import javax.swing.*; |
| | | import java.util.*; |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | import java.util.logging.Level; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * This class is responsible for doing the following: |
| | |
| | | * of flickering. So the idea here is to have a minimal time between 2 updates |
| | | * of the progress dialog (specified by UPDATE_PERIOD). |
| | | * |
| | | * @see #progressUpdate(ProgressUpdateEvent) |
| | | * @see #progressUpdate(org.opends.quicksetup.event.ProgressUpdateEvent) |
| | | */ |
| | | private void runDisplayUpdater() |
| | | { |
| | |
| | | return Utils.isWebStart(); |
| | | } |
| | | } |
| | | /** |
| | | * This class is just used to specify which are the default values that will be |
| | | * proposed to the user in the Data Options panel of the Installation wizard. |
| | | * |
| | | */ |
| | | class DefaultDataOptions extends DataOptions |
| | | { |
| | | /** |
| | | * Default constructor. |
| | | * |
| | | */ |
| | | public DefaultDataOptions() |
| | | { |
| | | super(Type.CREATE_BASE_ENTRY, "dc=example,dc=com"); |
| | | } |
| | | |
| | | /** |
| | | * Get the number of entries that will be automatically generated. |
| | | * |
| | | * @return the number of entries that will be automatically generated. |
| | | */ |
| | | public int getNumberEntries() |
| | | { |
| | | return 2000; |
| | | } |
| | | } |
| | |
| | | import java.awt.event.WindowAdapter; |
| | | import java.awt.event.WindowEvent; |
| | | import java.util.HashSet; |
| | | import java.util.logging.Logger; |
| | | import java.util.logging.Level; |
| | | |
| | | import javax.swing.JButton; |
| | | import javax.swing.JFrame; |
| | |
| | | import org.opends.quicksetup.event.ButtonEvent; |
| | | import org.opends.quicksetup.event.MinimumSizeComponentListener; |
| | | import org.opends.quicksetup.i18n.ResourceProvider; |
| | | import org.opends.quicksetup.installer.FieldName; |
| | | import org.opends.quicksetup.ProgressDescriptor; |
| | | import org.opends.quicksetup.util.ProgressMessageFormatter; |
| | | import org.opends.quicksetup.util.Utils; |
| | |
| | | */ |
| | | public class QuickSetupDialog |
| | | { |
| | | static private final Logger LOG = |
| | | Logger.getLogger(QuickSetupDialog.class.getName()); |
| | | |
| | | private JFrame frame; |
| | | |
| | | private QuickSetupErrorPanel installedPanel; |
| | |
| | | */ |
| | | public void setFocusOnButton(ButtonName buttonName) |
| | | { |
| | | getButton(buttonName).requestFocusInWindow(); |
| | | JButton button = getButton(buttonName); |
| | | if (button != null) { |
| | | button.requestFocusInWindow(); |
| | | } else { |
| | | LOG.log(Level.INFO, "Focus requested for unknown button '" + |
| | | buttonName + "'"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | if (installedPanel == null) |
| | | { |
| | | installedPanel = new QuickSetupErrorPanel(installStatus); |
| | | installedPanel = new QuickSetupErrorPanel( |
| | | application, |
| | | installStatus); |
| | | } |
| | | return installedPanel; |
| | | } |
| | |
| | | |
| | | /** |
| | | * Constructor of the QuickSetupErrorPanel. |
| | | * |
| | | * @param application Application this panel represents |
| | | * @param installStatus the current install status. |
| | | */ |
| | | public QuickSetupErrorPanel(CurrentInstallStatus installStatus) |
| | | public QuickSetupErrorPanel(GuiApplication application, |
| | | CurrentInstallStatus installStatus) |
| | | { |
| | | super(application); |
| | | JPanel p1 = new JPanel(new GridBagLayout()); |
| | | p1.setBackground(UIFactory.CURRENT_STEP_PANEL_BACKGROUND); |
| | | p1.setBorder(UIFactory.DIALOG_PANEL_BORDER); |
| | |
| | | { |
| | | private static final long serialVersionUID = 2096518919339628055L; |
| | | |
| | | private GuiApplication application; |
| | | |
| | | /** |
| | | * The basic constructor to be called by the subclasses. |
| | | * |
| | | * @param application Application this panel represents |
| | | */ |
| | | protected QuickSetupPanel() |
| | | protected QuickSetupPanel(GuiApplication application) |
| | | { |
| | | super(); |
| | | this.application = application; |
| | | setOpaque(false); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets the application this panel represents. |
| | | * @return GuiApplication this panel represents |
| | | */ |
| | | protected GuiApplication getApplication() { |
| | | return this.application; |
| | | } |
| | | |
| | | /** |
| | | * Returns a localized message for a key value. In the properties file we |
| | | * have something of type: |
| | | * key=value |
| | |
| | | import javax.swing.JPanel; |
| | | import javax.swing.event.HyperlinkEvent; |
| | | import javax.swing.event.HyperlinkListener; |
| | | import javax.swing.text.JTextComponent; |
| | | |
| | | import org.opends.quicksetup.event.ButtonActionListener; |
| | | import org.opends.quicksetup.event.ButtonEvent; |
| | | import org.opends.quicksetup.installer.FieldName; |
| | | import org.opends.quicksetup.ProgressDescriptor; |
| | | import org.opends.quicksetup.UserData; |
| | | import org.opends.quicksetup.util.HtmlProgressMessageFormatter; |
| | |
| | | new HashMap<String, URLWorker>(); |
| | | |
| | | /** |
| | | * Creates a default instance. |
| | | * @param application Application this panel represents |
| | | */ |
| | | public QuickSetupStepPanel(GuiApplication application) { |
| | | super(application); |
| | | } |
| | | |
| | | /** |
| | | * Initializes this panel. Called soon after creation. In general this |
| | | * is where maps should be populated etc. |
| | | */ |
| | | public void initialize() { |
| | | createLayout(); |
| | | } |
| | | |
| | | /** |
| | | * Called just before the panel is shown: used to update the contents of the |
| | | * panel with new UserData (used in particular in the review panel). |
| | | * |
| | |
| | | * Creates the layout of the panel. |
| | | * |
| | | */ |
| | | protected void createLayout() |
| | | private void createLayout() |
| | | { |
| | | setLayout(new GridBagLayout()); |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * Commodity method that returns a JTextComponent based on a |
| | | * LabelFieldDescriptor. |
| | | * @param desc the LabelFieldDescriptor describing the JTextField. |
| | | * @param defaultValue the default value used to initialize the |
| | | * JTextComponent. |
| | | * @return a JTextComponent based on a |
| | | * LabelFieldDescriptor. |
| | | */ |
| | | protected JTextComponent makeJTextComponent(LabelFieldDescriptor desc, |
| | | String defaultValue) |
| | | { |
| | | JTextComponent field; |
| | | switch (desc.getType()) |
| | | { |
| | | case TEXTFIELD: |
| | | |
| | | field = |
| | | UIFactory.makeJTextField(defaultValue, desc.getTooltip(), desc |
| | | .getSize(), UIFactory.TextStyle.TEXTFIELD); |
| | | break; |
| | | |
| | | case PASSWORD: |
| | | |
| | | field = |
| | | UIFactory.makeJPasswordField(defaultValue, desc.getTooltip(), desc |
| | | .getSize(), UIFactory.TextStyle.PASSWORD_FIELD); |
| | | break; |
| | | |
| | | case READ_ONLY: |
| | | |
| | | field = |
| | | UIFactory.makeTextPane(defaultValue, UIFactory.TextStyle.READ_ONLY); |
| | | break; |
| | | |
| | | default: |
| | | throw new IllegalArgumentException("Unknown type: " + desc.getType()); |
| | | } |
| | | return field; |
| | | } |
| | | |
| | | /** |
| | | * Commodity method that returns a JLabel based on a LabelFieldDescriptor. |
| | | * @param desc the LabelFieldDescriptor describing the JLabel. |
| | | * @return a JLabel based on a LabelFieldDescriptor. |
| | |
| | | |
| | | package org.opends.quicksetup.ui; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | | import java.awt.GridBagLayout; |
| | | import java.util.HashMap; |
| | | |
| | | import javax.swing.JCheckBox; |
| | | import javax.swing.JLabel; |
| | | import javax.swing.JPanel; |
| | | import javax.swing.text.JTextComponent; |
| | | |
| | | import org.opends.quicksetup.DataOptions; |
| | | import org.opends.quicksetup.UserData; |
| | | import org.opends.quicksetup.installer.FieldName; |
| | | import javax.swing.*; |
| | | import java.awt.*; |
| | | |
| | | /** |
| | | * This is the panel that contains the Review Panel. |
| | | * |
| | | * Abstract class for rendering a review panel with fields and value |
| | | * that the user can use to confirm an application's operation. |
| | | */ |
| | | public class ReviewPanel extends QuickSetupStepPanel |
| | | { |
| | | private static final long serialVersionUID = -7356174829193265699L; |
| | | |
| | | private boolean displayServerLocation; |
| | | |
| | | private UserData defaultUserData; |
| | | public abstract class ReviewPanel extends QuickSetupStepPanel { |
| | | |
| | | private JCheckBox checkBox; |
| | | |
| | | private HashMap<FieldName, JLabel> hmLabels = |
| | | new HashMap<FieldName, JLabel>(); |
| | | |
| | | private HashMap<FieldName, JTextComponent> hmFields = |
| | | new HashMap<FieldName, JTextComponent>(); |
| | | /** |
| | | * Creates an instance. |
| | | * @param application GuiApplication this panel represents |
| | | */ |
| | | public ReviewPanel(GuiApplication application) { |
| | | super(application); |
| | | } |
| | | |
| | | /** |
| | | * Constructor of the panel. |
| | | * @param defaultUserData the default values that must be used to initialize |
| | | * the fields of the panel. |
| | | * Creates the panel containing field names and values. |
| | | * @return JPanel containing fields and values |
| | | */ |
| | | public ReviewPanel(UserData defaultUserData) |
| | | { |
| | | this.defaultUserData = defaultUserData; |
| | | this.displayServerLocation = isWebStart(); |
| | | populateLabelAndFieldsMap(); |
| | | createLayout(); |
| | | } |
| | | protected abstract JPanel createFieldsPanel(); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void beginDisplay(UserData userData) |
| | | { |
| | | if (displayServerLocation) |
| | | { |
| | | setFieldValue(FieldName.SERVER_LOCATION, userData.getServerLocation()); |
| | | } |
| | | setFieldValue(FieldName.SERVER_PORT, String.valueOf(userData |
| | | .getServerPort())); |
| | | setFieldValue(FieldName.DIRECTORY_MANAGER_DN, userData |
| | | .getDirectoryManagerDn()); |
| | | setFieldValue(FieldName.DIRECTORY_BASE_DN, userData.getDataOptions() |
| | | .getBaseDn()); |
| | | setFieldValue(FieldName.DATA_OPTIONS, getDisplayString(userData |
| | | .getDataOptions())); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Object getFieldValue(FieldName fieldName) |
| | | { |
| | | Object value = null; |
| | | if (fieldName == FieldName.SERVER_START) |
| | | { |
| | | value = getCheckBox().isSelected(); |
| | | } |
| | | return value; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected Component createInputPanel() |
| | | final protected Component createInputPanel() |
| | | { |
| | | JPanel panel = new JPanel(new GridBagLayout()); |
| | | panel.setOpaque(false); |
| | |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected String getInstructions() |
| | | { |
| | | return getMsg("review-panel-instructions"); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected String getTitle() |
| | | { |
| | | return getMsg("review-panel-title"); |
| | | } |
| | | |
| | | /** |
| | | * Create the components and populate the Maps. |
| | | */ |
| | | private void populateLabelAndFieldsMap() |
| | | { |
| | | HashMap<FieldName, LabelFieldDescriptor> hm = |
| | | new HashMap<FieldName, LabelFieldDescriptor>(); |
| | | |
| | | if (displayServerLocation) |
| | | { |
| | | hm.put(FieldName.SERVER_LOCATION, new LabelFieldDescriptor( |
| | | getMsg("server-location-label"), getMsg("server-port-tooltip"), |
| | | LabelFieldDescriptor.FieldType.READ_ONLY, |
| | | LabelFieldDescriptor.LabelType.PRIMARY, 0)); |
| | | } |
| | | |
| | | hm.put(FieldName.SERVER_PORT, new LabelFieldDescriptor( |
| | | getMsg("server-port-label"), getMsg("server-port-tooltip"), |
| | | LabelFieldDescriptor.FieldType.READ_ONLY, |
| | | LabelFieldDescriptor.LabelType.PRIMARY, 0)); |
| | | |
| | | hm.put(FieldName.DIRECTORY_MANAGER_DN, new LabelFieldDescriptor( |
| | | getMsg("server-directory-manager-dn-label"), |
| | | getMsg("server-directory-manager-dn-tooltip"), |
| | | LabelFieldDescriptor.FieldType.READ_ONLY, |
| | | LabelFieldDescriptor.LabelType.PRIMARY, 0)); |
| | | |
| | | hm.put(FieldName.DIRECTORY_BASE_DN, new LabelFieldDescriptor( |
| | | getMsg("base-dn-label"), getMsg("base-dn-tooltip"), |
| | | LabelFieldDescriptor.FieldType.READ_ONLY, |
| | | LabelFieldDescriptor.LabelType.PRIMARY, 0)); |
| | | |
| | | hm.put(FieldName.DATA_OPTIONS, new LabelFieldDescriptor( |
| | | getMsg("directory-data-label"), null, |
| | | LabelFieldDescriptor.FieldType.READ_ONLY, |
| | | LabelFieldDescriptor.LabelType.PRIMARY, 0)); |
| | | for (FieldName fieldName : hm.keySet()) |
| | | { |
| | | LabelFieldDescriptor desc = hm.get(fieldName); |
| | | |
| | | JTextComponent field = makeJTextComponent(desc, null); |
| | | field.setOpaque(false); |
| | | JLabel label = makeJLabel(desc); |
| | | |
| | | hmFields.put(fieldName, field); |
| | | label.setLabelFor(field); |
| | | |
| | | hmLabels.put(fieldName, label); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns the label associated with the given field name. |
| | | * @param fieldName the field name for which we want to retrieve the JLabel. |
| | | * @return the label associated with the given field name. |
| | | */ |
| | | private JLabel getLabel(FieldName fieldName) |
| | | { |
| | | return hmLabels.get(fieldName); |
| | | } |
| | | |
| | | /** |
| | | * Returns the JTextComponent associated with the given field name. |
| | | * @param fieldName the field name for which we want to retrieve the |
| | | * JTextComponent. |
| | | * @return the JTextComponent associated with the given field name. |
| | | */ |
| | | private JTextComponent getField(FieldName fieldName) |
| | | { |
| | | return hmFields.get(fieldName); |
| | | } |
| | | |
| | | /** |
| | | * Updates the JTextComponent associated with a FieldName with a text value. |
| | | * @param fieldName the field name of the JTextComponent that we want to |
| | | * update. |
| | | * @param value the value to be set. |
| | | */ |
| | | private void setFieldValue(FieldName fieldName, String value) |
| | | { |
| | | getField(fieldName).setText(value); |
| | | } |
| | | |
| | | /** |
| | | * Returns the localized string describing the DataOptions chosen by the user. |
| | | * @param options the DataOptions of the user. |
| | | * @return the localized string describing the DataOptions chosen by the user. |
| | | */ |
| | | private String getDisplayString(DataOptions options) |
| | | { |
| | | String msg; |
| | | |
| | | switch (options.getType()) |
| | | { |
| | | case CREATE_BASE_ENTRY: |
| | | msg = getMsg("review-create-base-entry-label", new String[] |
| | | { options.getBaseDn() }); |
| | | |
| | | break; |
| | | |
| | | case LEAVE_DATABASE_EMPTY: |
| | | msg = getMsg("review-leave-database-empty-label"); |
| | | break; |
| | | |
| | | case IMPORT_FROM_LDIF_FILE: |
| | | msg = getMsg("review-import-ldif", new String[] |
| | | { options.getLDIFPath() }); |
| | | break; |
| | | |
| | | case IMPORT_AUTOMATICALLY_GENERATED_DATA: |
| | | msg = getMsg("review-import-automatically-generated", new String[] |
| | | { String.valueOf(options.getNumberEntries()) }); |
| | | break; |
| | | |
| | | default: |
| | | throw new IllegalArgumentException("Unknow type: " + options.getType()); |
| | | |
| | | } |
| | | |
| | | return msg; |
| | | } |
| | | |
| | | /** |
| | | * Returns the start server check box. |
| | | * If it does not exist creates the start server check box. |
| | | * @return the start server check box. |
| | | */ |
| | | private JCheckBox getCheckBox() |
| | | protected JCheckBox getCheckBox() |
| | | { |
| | | if (checkBox == null) |
| | | { |
| | |
| | | UIFactory.makeJCheckBox(getMsg("start-server-label"), |
| | | getMsg("start-server-tooltip"), UIFactory.TextStyle.CHECKBOX); |
| | | checkBox.setOpaque(false); |
| | | checkBox.setSelected(defaultUserData.getStartServer()); |
| | | checkBox.setSelected(getApplication().getUserData().getStartServer()); |
| | | } |
| | | return checkBox; |
| | | } |
| | | |
| | | /** |
| | | * Returns and creates the fields panel. |
| | | * @return the fields panel. |
| | | */ |
| | | private JPanel createFieldsPanel() |
| | | { |
| | | JPanel panel = new JPanel(new GridBagLayout()); |
| | | panel.setOpaque(false); |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | |
| | | FieldName[] fieldNames; |
| | | if (displayServerLocation) |
| | | { |
| | | fieldNames = |
| | | new FieldName[] |
| | | { FieldName.SERVER_LOCATION, FieldName.SERVER_PORT, |
| | | FieldName.DIRECTORY_MANAGER_DN, |
| | | FieldName.DIRECTORY_BASE_DN, |
| | | FieldName.DATA_OPTIONS }; |
| | | } else |
| | | { |
| | | fieldNames = |
| | | new FieldName[] |
| | | { FieldName.SERVER_PORT, FieldName.DIRECTORY_MANAGER_DN, |
| | | FieldName.DIRECTORY_BASE_DN, FieldName.DATA_OPTIONS }; |
| | | } |
| | | |
| | | for (int i = 0; i < fieldNames.length; i++) |
| | | { |
| | | gbc.gridwidth = GridBagConstraints.RELATIVE; |
| | | gbc.weightx = 0.0; |
| | | if (i > 0) |
| | | { |
| | | gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD; |
| | | } else |
| | | { |
| | | gbc.insets.top = 0; |
| | | } |
| | | gbc.insets.left = 0; |
| | | gbc.anchor = GridBagConstraints.NORTHWEST; |
| | | panel.add(getLabel(fieldNames[i]), gbc); |
| | | |
| | | JPanel auxPanel = new JPanel(new GridBagLayout()); |
| | | auxPanel.setOpaque(false); |
| | | gbc.weightx = 1.0; |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | if (i > 0) |
| | | { |
| | | gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD; |
| | | } else |
| | | { |
| | | gbc.insets.top = 0; |
| | | } |
| | | gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD; |
| | | |
| | | gbc.gridwidth = GridBagConstraints.REMAINDER; |
| | | panel.add(auxPanel, gbc); |
| | | |
| | | gbc.insets = UIFactory.getEmptyInsets(); |
| | | gbc.gridwidth = GridBagConstraints.REMAINDER; |
| | | gbc.weightx = 1.0; |
| | | auxPanel.add(getField(fieldNames[i]), gbc); |
| | | } |
| | | |
| | | return panel; |
| | | } |
| | | } |
| | |
| | | import javax.swing.text.JTextComponent; |
| | | |
| | | import org.opends.quicksetup.event.BrowseActionListener; |
| | | import org.opends.quicksetup.installer.FieldName; |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.quicksetup.UserData; |
| | | |
| | |
| | | |
| | | /** |
| | | * Constructor of the panel. |
| | | * @param defaultUserData the default values that must be used to initialize |
| | | * @param application Application this panel represents |
| | | * the fields of the panel. |
| | | */ |
| | | public ServerSettingsPanel(UserData defaultUserData) |
| | | public ServerSettingsPanel(GuiApplication application) |
| | | { |
| | | this.defaultUserData = defaultUserData; |
| | | super(application); |
| | | this.defaultUserData = application.getUserData(); |
| | | this.displayServerLocation = isWebStart(); |
| | | populateLabelAndFieldMaps(); |
| | | createLayout(); |
| | | addFocusListeners(); |
| | | } |
| | | |
| | |
| | | { |
| | | LabelFieldDescriptor desc = hm.get(fieldName); |
| | | String defaultValue = getDefaultValue(fieldName); |
| | | JTextComponent field = makeJTextComponent(desc, defaultValue); |
| | | JTextComponent field = UIFactory.makeJTextComponent(desc, defaultValue); |
| | | JLabel label = makeJLabel(desc); |
| | | |
| | | hmFields.put(fieldName, field); |
| | |
| | | LabelFieldDescriptor.FieldType.TEXTFIELD, |
| | | LabelFieldDescriptor.LabelType.PRIMARY, UIFactory.PATH_FIELD_SIZE); |
| | | lServerLocation = makeJLabel(desc); |
| | | tfServerLocationParent = makeJTextComponent(desc, ""); |
| | | tfServerLocationParent = UIFactory.makeJTextComponent(desc, ""); |
| | | lServerLocation.setLabelFor(tfServerLocationParent); |
| | | |
| | | desc = |
| | |
| | | LabelFieldDescriptor.FieldType.TEXTFIELD, |
| | | LabelFieldDescriptor.LabelType.PRIMARY, |
| | | UIFactory.RELATIVE_PATH_FIELD_SIZE); |
| | | tfServerLocationRelativePath = makeJTextComponent(desc, ""); |
| | | tfServerLocationRelativePath = UIFactory.makeJTextComponent(desc, ""); |
| | | String defaultPath = getDefaultValue(FieldName.SERVER_LOCATION); |
| | | if (defaultPath != null) |
| | | { |
| | |
| | | import javax.swing.JLabel; |
| | | import javax.swing.JPanel; |
| | | |
| | | import org.opends.quicksetup.GuiApplication; |
| | | import org.opends.quicksetup.WizardStep; |
| | | |
| | | /** |
| | |
| | | |
| | | HashMap<WizardStep, JLabel> hmIcons = new HashMap<WizardStep, JLabel>(); |
| | | |
| | | GuiApplication application = null; |
| | | |
| | | /** |
| | | * Creates a StepsPanel. |
| | | * @param app Application whose steps this class represents |
| | | */ |
| | | public StepsPanel(GuiApplication app) |
| | | { |
| | | this.application = app; |
| | | super(app); |
| | | createLayout(app); |
| | | } |
| | | |
| | |
| | | */ |
| | | public void setDisplayedStep(WizardStep step) |
| | | { |
| | | for (WizardStep s : application.getWizardSteps()) |
| | | for (WizardStep s : getApplication().getWizardSteps()) |
| | | { |
| | | if (s.equals(step)) |
| | | { |
| | |
| | | import java.awt.Toolkit; |
| | | import java.util.HashMap; |
| | | |
| | | import javax.swing.BorderFactory; |
| | | import javax.swing.ImageIcon; |
| | | import javax.swing.JButton; |
| | | import javax.swing.JCheckBox; |
| | | import javax.swing.JComponent; |
| | | import javax.swing.JEditorPane; |
| | | import javax.swing.JFrame; |
| | | import javax.swing.JLabel; |
| | | import javax.swing.JList; |
| | | import javax.swing.JPasswordField; |
| | | import javax.swing.JRadioButton; |
| | | import javax.swing.JScrollBar; |
| | | import javax.swing.JScrollPane; |
| | | import javax.swing.JTextField; |
| | | import javax.swing.ListCellRenderer; |
| | | import javax.swing.UIManager; |
| | | import javax.swing.*; |
| | | import javax.swing.text.JTextComponent; |
| | | import javax.swing.border.Border; |
| | | import javax.swing.border.EmptyBorder; |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * Creates a JComboBox. |
| | | * @return JComboBox a new combo box |
| | | */ |
| | | static public JComboBox makeJComboBox() { |
| | | return new JComboBox(); |
| | | } |
| | | |
| | | /** |
| | | * Creates a JButton with the given label and tooltip. |
| | | * @param label the text of the button. |
| | | * @param tooltip the tooltip of the button. |
| | |
| | | } |
| | | |
| | | /** |
| | | * Commodity method that returns a JLabel based on a LabelFieldDescriptor. |
| | | * @param desc the LabelFieldDescriptor describing the JLabel. |
| | | * @return a JLabel based on a LabelFieldDescriptor. |
| | | */ |
| | | static public JLabel makeJLabel(LabelFieldDescriptor desc) |
| | | { |
| | | UIFactory.TextStyle style; |
| | | if (desc.getLabelType() == LabelFieldDescriptor.LabelType.PRIMARY) |
| | | { |
| | | style = UIFactory.TextStyle.PRIMARY_FIELD_VALID; |
| | | } else |
| | | { |
| | | style = UIFactory.TextStyle.SECONDARY_FIELD_VALID; |
| | | } |
| | | return makeJLabel(UIFactory.IconType.NO_ICON, desc.getLabel(), style); |
| | | } |
| | | |
| | | /** |
| | | * Creates a JLabel with the given icon, text and text style. |
| | | * @param iconName the icon. |
| | | * @param text the label text. |
| | |
| | | } |
| | | |
| | | /** |
| | | * Commodity method that returns a JTextComponent based on a |
| | | * LabelFieldDescriptor. |
| | | * @param desc the LabelFieldDescriptor describing the JTextField. |
| | | * @param defaultValue the default value used to initialize the |
| | | * JTextComponent. |
| | | * @return a JTextComponent based on a |
| | | * LabelFieldDescriptor. |
| | | */ |
| | | static public JTextComponent makeJTextComponent(LabelFieldDescriptor desc, |
| | | String defaultValue) |
| | | { |
| | | JTextComponent field; |
| | | switch (desc.getType()) |
| | | { |
| | | case TEXTFIELD: |
| | | |
| | | field = |
| | | makeJTextField(defaultValue, desc.getTooltip(), desc |
| | | .getSize(), TextStyle.TEXTFIELD); |
| | | break; |
| | | |
| | | case PASSWORD: |
| | | |
| | | field = |
| | | makeJPasswordField(defaultValue, desc.getTooltip(), desc |
| | | .getSize(), TextStyle.PASSWORD_FIELD); |
| | | break; |
| | | |
| | | case READ_ONLY: |
| | | |
| | | field = |
| | | makeTextPane(defaultValue, TextStyle.READ_ONLY); |
| | | break; |
| | | |
| | | default: |
| | | throw new IllegalArgumentException("Unknown type: " + desc.getType()); |
| | | } |
| | | return field; |
| | | } |
| | | |
| | | /** |
| | | * Creates a JTextField with the given icon, tooltip text, size and text |
| | | * style. |
| | | * @param text the text. |
| | |
| | | */ |
| | | public static ImageIcon getImageIcon(IconType iconType) |
| | | { |
| | | if (iconType == null) { |
| | | iconType = IconType.NO_ICON; |
| | | } |
| | | ImageIcon icon = hmIcons.get(iconType); |
| | | if ((icon == null) && (iconType != IconType.NO_ICON)) |
| | | { |
| | |
| | | setTextStyle(pane, style); |
| | | pane.setEditable(false); |
| | | pane.setBorder(new EmptyBorder(0, 0, 0, 0)); |
| | | pane.setOpaque(false); |
| | | return pane; |
| | | } |
| | | |
| | |
| | | */ |
| | | private static String getIconTooltip(IconType iconType) |
| | | { |
| | | if (iconType == null) { |
| | | iconType = IconType.NO_ICON; |
| | | } |
| | | String tooltip; |
| | | switch (iconType) |
| | | { |
| New file |
| | |
| | | /* |
| | | * 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 |
| | | * |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.quicksetup.ui; |
| | | |
| | | import javax.swing.*; |
| | | import javax.swing.text.JTextComponent; |
| | | import java.awt.*; |
| | | |
| | | /** |
| | | * A set of utilities specific to GUI QuickSetup applications. |
| | | */ |
| | | public class Utilities { |
| | | |
| | | /** |
| | | * Creates a panel with a field and a browse button. |
| | | * @param lbl JLabel for the field |
| | | * @param tf JTextField for holding the browsed data |
| | | * @param but JButton for invoking browse action |
| | | * @return the created panel. |
| | | */ |
| | | static public JPanel createBrowseButtonPanel(JLabel lbl, |
| | | JTextComponent tf, |
| | | JButton but) |
| | | { |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | |
| | | JPanel panel = new JPanel(new GridBagLayout()); |
| | | panel.setOpaque(false); |
| | | gbc.insets = UIFactory.getEmptyInsets(); |
| | | gbc.gridwidth = 4; |
| | | gbc.weightx = 0.0; |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | panel.add(lbl, gbc); |
| | | |
| | | gbc.insets.left = UIFactory.LEFT_INSET_SECONDARY_FIELD; |
| | | gbc.gridwidth--; |
| | | gbc.weightx = 0.1; |
| | | panel.add(tf, gbc); |
| | | |
| | | gbc.insets.left = UIFactory.LEFT_INSET_BROWSE; |
| | | gbc.gridwidth = GridBagConstraints.RELATIVE; |
| | | panel.add(but, gbc); |
| | | |
| | | gbc.weightx = 1.0; |
| | | gbc.gridwidth = GridBagConstraints.REMAINDER; |
| | | panel.add(Box.createHorizontalGlue(), gbc); |
| | | |
| | | return panel; |
| | | } |
| | | |
| | | } |
| | |
| | | import org.opends.quicksetup.*; |
| | | import static org.opends.quicksetup.Step.PROGRESS; |
| | | import static org.opends.quicksetup.Step.REVIEW; |
| | | import org.opends.quicksetup.installer.FieldName; |
| | | import org.opends.quicksetup.ui.FieldName; |
| | | import org.opends.quicksetup.ui.*; |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.quicksetup.util.BackgroundTask; |
| | |
| | | public QuickSetupStepPanel createWizardStepPanel(WizardStep step) { |
| | | QuickSetupStepPanel p = null; |
| | | if (step == Step.CONFIRM_UNINSTALL) { |
| | | p = new ConfirmUninstallPanel(installStatus); |
| | | p = new ConfirmUninstallPanel(this, installStatus); |
| | | } else if (step == Step.PROGRESS) { |
| | | p = new ProgressPanel(); |
| | | p = new ProgressPanel(this); |
| | | } |
| | | return p; |
| | | } |
| | |
| | | if (args != null) { |
| | | for (int i = 0; i < args.length; i++) { |
| | | if (args[i].equals("--" + UpgraderCliHelper.FILE_OPTION_LONG) || |
| | | args[i].equals("-" + UpgraderCliHelper.FILE_OPTION_SHORT)) { |
| | | args[i].equalsIgnoreCase( |
| | | "-" + UpgraderCliHelper.FILE_OPTION_SHORT)) { |
| | | if (i < args.length - 1) { |
| | | buildFileName = args[i+ 1]; |
| | | } |
| New file |
| | |
| | | /* |
| | | * 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 |
| | | * |
| | | * |
| | | * Portions Copyright 2007 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.quicksetup.upgrader; |
| | | |
| | | import org.opends.quicksetup.Application; |
| | | |
| | | import java.net.URL; |
| | | import java.net.Proxy; |
| | | import java.net.URLConnection; |
| | | import java.util.*; |
| | | import java.util.regex.Pattern; |
| | | import java.util.regex.Matcher; |
| | | import java.util.logging.Logger; |
| | | import java.io.*; |
| | | |
| | | /** |
| | | * Manages listing and retreival of build packages on a remote host. |
| | | */ |
| | | public class RemoteBuildManager { |
| | | |
| | | static private final Logger LOG = |
| | | Logger.getLogger(RemoteBuildManager.class.getName()); |
| | | |
| | | /** |
| | | * Describes build types. |
| | | */ |
| | | enum BuildType { |
| | | |
| | | NIGHTLY, |
| | | |
| | | WEEKLY |
| | | |
| | | } |
| | | |
| | | /** |
| | | * Representation of an OpenDS build package. |
| | | */ |
| | | public class Build { |
| | | |
| | | private URL url; |
| | | private String id; |
| | | |
| | | /** |
| | | * Creates an instance. |
| | | * @param url where the build package can be accessed |
| | | * @param id of the new build |
| | | */ |
| | | Build(URL url, String id) { |
| | | this.url = url; |
| | | this.id = id; |
| | | } |
| | | |
| | | /** |
| | | * Gets the URL where the build can be accessed. |
| | | * @return URL representing access to the build package |
| | | */ |
| | | public URL getUrl() { |
| | | return url; |
| | | } |
| | | |
| | | /** |
| | | * Gets the builds ID number, a 14 digit number representing the time |
| | | * the build was created. |
| | | * @return String represenging the build |
| | | */ |
| | | public String getId() { |
| | | return id; |
| | | } |
| | | |
| | | } |
| | | |
| | | private Application app; |
| | | |
| | | private Proxy proxy; |
| | | |
| | | private URL url; |
| | | |
| | | /** |
| | | * Creates an instance. |
| | | * @param app using this tool |
| | | * @param url base context for an OpenDS build repository |
| | | */ |
| | | public RemoteBuildManager(Application app, URL url) { |
| | | this.app = app; |
| | | this.url = url; |
| | | } |
| | | |
| | | /** |
| | | * Gets a list of builds found in the remote repository. |
| | | * @return List of Build objects representing remote builds |
| | | * @throws IOException if there was a problem contacting the build |
| | | * repository |
| | | */ |
| | | public List<Build> listBuilds() throws IOException { |
| | | List<Build> buildList = new ArrayList<Build>(); |
| | | String dailyBuildsPage = getDailyBuildsPage(); |
| | | Pattern p = Pattern.compile("\\d{14}"); |
| | | Matcher m = p.matcher(dailyBuildsPage); |
| | | Set<String> buildIds = new HashSet<String>(); |
| | | while (m.find()) { |
| | | buildIds.add(dailyBuildsPage.substring(m.start(), m.end())); |
| | | } |
| | | for (String buildId : buildIds) { |
| | | buildList.add(new Build(url, buildId)); |
| | | } |
| | | return buildList; |
| | | } |
| | | |
| | | private String getDailyBuildsPage() throws IOException { |
| | | URL dailyBuildsUrl = new URL(url, "daily-builds"); |
| | | URLConnection conn; |
| | | if (proxy == null) { |
| | | conn = dailyBuildsUrl.openConnection(); |
| | | } else { |
| | | conn = dailyBuildsUrl.openConnection(proxy); |
| | | } |
| | | InputStream in = conn.getInputStream(); |
| | | BufferedReader reader = new BufferedReader(new InputStreamReader(in)); |
| | | StringBuilder builder = new StringBuilder(); |
| | | String line; |
| | | while (null != (line = reader.readLine())) { |
| | | builder.append(line); |
| | | } |
| | | return builder.toString(); |
| | | } |
| | | |
| | | /** |
| | | * Downloads a particular build from the build repository to a specific |
| | | * location on the local file system. |
| | | * @param build to download |
| | | * @param destination directory for the newly downloaded file |
| | | */ |
| | | public void download(Build build, File destination) { |
| | | |
| | | } |
| | | |
| | | /** |
| | | * For testing only. |
| | | * @param args command line arguments |
| | | */ |
| | | public static void main(String[] args) { |
| | | try { |
| | | Properties systemSettings = System.getProperties(); |
| | | systemSettings.put("http.proxyHost", "webcache.central.sun.com"); |
| | | systemSettings.put("http.proxyPort", "8080"); |
| | | System.setProperties(systemSettings); |
| | | URL url = new URL("http://builds.opends.org"); |
| | | RemoteBuildManager rbm = new RemoteBuildManager(null, url); |
| | | List<Build> builds = rbm.listBuilds(); |
| | | for (Build build : builds) { |
| | | System.out.println("build " + build.getId()); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | package org.opends.quicksetup.upgrader; |
| | | |
| | | import org.opends.quicksetup.*; |
| | | import org.opends.quicksetup.upgrader.ui.WelcomePanel; |
| | | import org.opends.quicksetup.upgrader.ui.ChooseVersionPanel; |
| | | import org.opends.quicksetup.upgrader.ui.UpgraderReviewPanel; |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.quicksetup.util.FileManager; |
| | | import org.opends.quicksetup.util.ServerController; |
| | | import org.opends.quicksetup.ui.QuickSetupDialog; |
| | | import org.opends.quicksetup.ui.QuickSetupStepPanel; |
| | | import org.opends.quicksetup.ui.*; |
| | | import org.opends.server.tools.BackUpDB; |
| | | import org.opends.server.tools.LDIFDiff; |
| | | import org.opends.server.util.*; |
| | |
| | | private UpgraderCliHelper cliHelper = null; |
| | | |
| | | /** |
| | | * Directory where we keep files temporarily. |
| | | */ |
| | | private File stagingDirectory = null; |
| | | |
| | | /** |
| | | * Directory where backup is kept in case the upgrade needs reversion. |
| | | */ |
| | | private File backupDirectory = null; |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public QuickSetupStepPanel createWizardStepPanel(WizardStep step) { |
| | | return null; |
| | | QuickSetupStepPanel pnl = null; |
| | | if (UpgradeWizardStep.WELCOME.equals(step)) { |
| | | pnl = new WelcomePanel(this); |
| | | } else if (UpgradeWizardStep.CHOOSE_VERSION.equals(step)) { |
| | | pnl = new ChooseVersionPanel(this); |
| | | } else if (UpgradeWizardStep.REVIEW.equals(step)) { |
| | | pnl = new UpgraderReviewPanel(this); |
| | | } else if (UpgradeWizardStep.PROGRESS.equals(step)) { |
| | | pnl = new ProgressPanel(this); |
| | | } |
| | | return pnl; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Step getNextWizardStep(WizardStep step) { |
| | | return null; |
| | | public WizardStep getNextWizardStep(WizardStep step) { |
| | | WizardStep next = null; |
| | | if (UpgradeWizardStep.WELCOME.equals(step)) { |
| | | next = UpgradeWizardStep.CHOOSE_VERSION; |
| | | } else if (UpgradeWizardStep.CHOOSE_VERSION.equals(step)) { |
| | | next = UpgradeWizardStep.REVIEW; |
| | | } else if (UpgradeWizardStep.REVIEW.equals(step)) { |
| | | next = UpgradeWizardStep.PROGRESS; |
| | | } |
| | | return next; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public WizardStep getPreviousWizardStep(WizardStep step) { |
| | | return null; |
| | | WizardStep prev = null; |
| | | if (UpgradeWizardStep.PROGRESS.equals(step)) { |
| | | prev = UpgradeWizardStep.REVIEW; |
| | | } else if (UpgradeWizardStep.REVIEW.equals(step)) { |
| | | prev = UpgradeWizardStep.CHOOSE_VERSION; |
| | | } else if (UpgradeWizardStep.CHOOSE_VERSION.equals(step)) { |
| | | prev = UpgradeWizardStep.WELCOME; |
| | | } |
| | | return prev; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean canCancel(WizardStep step) { |
| | | return UpgradeWizardStep.WELCOME == step || |
| | | UpgradeWizardStep.CHOOSE_VERSION == step || |
| | | UpgradeWizardStep.REVIEW == step; |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected void updateUserData(WizardStep cStep, QuickSetup qs) |
| | | public void updateUserData(WizardStep cStep, QuickSetup qs) |
| | | throws UserDataException { |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public void cancelClicked(WizardStep cStep, QuickSetup qs) { |
| | | // TODO: confirm cancel |
| | | System.exit(1); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean canFinish(WizardStep step) { |
| | | return UpgradeWizardStep.REVIEW.equals(step); |
| | | } |
| | | |
| | | /** |
| | |
| | | public class UpgraderCliHelper extends CliApplicationHelper { |
| | | |
| | | /** Short form of the option for specifying the installation package file. */ |
| | | static public final Character FILE_OPTION_SHORT = 'F'; |
| | | static public final Character FILE_OPTION_SHORT = 'f'; |
| | | |
| | | /** Long form of the option for specifying the installation package file. */ |
| | | static public final String FILE_OPTION_LONG = "file"; |
| | |
| | | } else { |
| | | // TODO i18N |
| | | throw new UserDataException(null, |
| | | "-F must be present"); |
| | | "-f must be present"); |
| | | } |
| | | |
| | | } catch (ArgumentException e) { |
| New file |
| | |
| | | /* |
| | | * 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 |
| | | * |
| | | * |
| | | * Portions Copyright 2007 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.quicksetup.upgrader.ui; |
| | | |
| | | import org.opends.quicksetup.ui.QuickSetupStepPanel; |
| | | import org.opends.quicksetup.ui.UIFactory; |
| | | import org.opends.quicksetup.ui.Utilities; |
| | | import org.opends.quicksetup.ui.GuiApplication; |
| | | |
| | | import javax.swing.*; |
| | | import java.awt.*; |
| | | |
| | | /** |
| | | * This panel allows the user to select a remote or local build for upgrade. |
| | | */ |
| | | public class ChooseVersionPanel extends QuickSetupStepPanel { |
| | | |
| | | private static final long serialVersionUID = -6941309163077121917L; |
| | | |
| | | /** |
| | | * Creates an instance. |
| | | * @param application this panel represents. |
| | | */ |
| | | public ChooseVersionPanel(GuiApplication application) { |
| | | super(application); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected Component createInputPanel() { |
| | | Component c; |
| | | |
| | | JPanel p = new JPanel(); |
| | | |
| | | JRadioButton rbRemote = UIFactory.makeJRadioButton( |
| | | getMsg("upgrade-choose-version-remote-label"), |
| | | getMsg("upgrade-choose-version-remote-tooltip"), |
| | | UIFactory.TextStyle.SECONDARY_FIELD_VALID); |
| | | |
| | | JRadioButton rbLocal = UIFactory.makeJRadioButton( |
| | | getMsg("upgrade-choose-version-local-label"), |
| | | getMsg("upgrade-choose-version-local-tooltip"), |
| | | UIFactory.TextStyle.SECONDARY_FIELD_VALID); |
| | | |
| | | JComboBox cboBuild = UIFactory.makeJComboBox(); |
| | | cboBuild.setModel(createBuildComboBoxModel()); |
| | | |
| | | // TODO: use UIFactory |
| | | JTextField tfBuild = new JTextField(); |
| | | tfBuild.setColumns(20); |
| | | |
| | | JPanel pnlBrowse = Utilities.createBrowseButtonPanel( |
| | | UIFactory.makeJLabel(null, |
| | | getMsg("upgrade-choose-version-local-path"), |
| | | UIFactory.TextStyle.SECONDARY_FIELD_VALID), |
| | | tfBuild, |
| | | UIFactory.makeJButton(getMsg("browse-button-label"), |
| | | getMsg("browse-button-tooltip"))); |
| | | |
| | | p.setLayout(new GridBagLayout()); |
| | | // p.setBorder(BorderFactory.createLineBorder(Color.RED)); |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | gbc.gridx = 0; |
| | | gbc.gridy = 0; |
| | | gbc.gridwidth = GridBagConstraints.REMAINDER; |
| | | gbc.insets = UIFactory.getEmptyInsets(); |
| | | gbc.weightx = 1.0; |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | gbc.insets = UIFactory.getEmptyInsets(); |
| | | gbc.insets.top = 15; // non-standard but looks better |
| | | gbc.anchor = GridBagConstraints.FIRST_LINE_START; |
| | | p.add(rbRemote, gbc); |
| | | |
| | | gbc.gridy = 1; |
| | | gbc.gridwidth = 1; |
| | | gbc.insets = UIFactory.getEmptyInsets(); |
| | | gbc.insets.top = UIFactory.TOP_INSET_RADIO_SUBORDINATE; |
| | | gbc.insets.left = UIFactory.LEFT_INSET_RADIO_SUBORDINATE; |
| | | gbc.anchor = GridBagConstraints.LINE_START; |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | gbc.weightx = 2; |
| | | p.add(cboBuild, gbc); |
| | | |
| | | gbc.gridy = 1; |
| | | gbc.gridx = 1; |
| | | gbc.weightx = 1.5; |
| | | gbc.anchor = GridBagConstraints.CENTER; |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | gbc.insets = UIFactory.getEmptyInsets(); |
| | | JPanel fill = new JPanel(); |
| | | // fill.setBorder(BorderFactory.createLineBorder(Color.BLUE)); |
| | | p.add(fill, gbc); |
| | | |
| | | gbc.gridy = 2; |
| | | gbc.gridx = 0; |
| | | gbc.insets = UIFactory.getEmptyInsets(); |
| | | gbc.insets.top = 15; // UIFactory.TOP_INSET_RADIOBUTTON; |
| | | p.add(rbLocal, gbc); |
| | | |
| | | gbc.gridy = 3; |
| | | gbc.insets = UIFactory.getEmptyInsets(); |
| | | gbc.insets.top = UIFactory.TOP_INSET_RADIO_SUBORDINATE; |
| | | gbc.insets.left = UIFactory.LEFT_INSET_RADIO_SUBORDINATE; |
| | | p.add(pnlBrowse, gbc); |
| | | |
| | | gbc.gridy = 4; |
| | | gbc.weighty = 1.0; |
| | | gbc.weightx = 1.0; |
| | | gbc.fill = GridBagConstraints.BOTH; |
| | | gbc.anchor = GridBagConstraints.LINE_START; |
| | | JPanel fill2 = new JPanel(); |
| | | //fill.setBorder(BorderFactory.createLineBorder(Color.BLUE)); |
| | | p.add(fill2, gbc); |
| | | |
| | | |
| | | c = p; |
| | | return c; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected String getTitle() { |
| | | return getMsg("upgrade-choose-version-panel-title"); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected String getInstructions() { |
| | | return getMsg("upgrade-choose-version-panel-instructions"); |
| | | } |
| | | |
| | | private ComboBoxModel createBuildComboBoxModel() { |
| | | // TODO: populate a list model with builds. |
| | | ComboBoxModel cbm = new DefaultComboBoxModel(new String[] {"xx","YY","ZZ"}); |
| | | return cbm; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * 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 |
| | | * |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.quicksetup.upgrader.ui; |
| | | |
| | | import org.opends.quicksetup.ui.ReviewPanel; |
| | | import org.opends.quicksetup.ui.UIFactory; |
| | | import org.opends.quicksetup.ui.LabelFieldDescriptor; |
| | | import org.opends.quicksetup.upgrader.Upgrader; |
| | | |
| | | import javax.swing.*; |
| | | import java.awt.*; |
| | | |
| | | /** |
| | | * Presents upgrade information to the user to confirm before starting the |
| | | * actual upgrade. |
| | | */ |
| | | public class UpgraderReviewPanel extends ReviewPanel { |
| | | |
| | | private static final long serialVersionUID = 5942916658585976799L; |
| | | |
| | | /** |
| | | * Creates an instance. |
| | | * @param application Application represented by this panel |
| | | */ |
| | | public UpgraderReviewPanel(Upgrader application) { |
| | | super(application); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected String getTitle() { |
| | | return getMsg("upgrade-review-panel-title"); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected String getInstructions() { |
| | | return getMsg("upgrade-review-panel-instructions"); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected JPanel createFieldsPanel() { |
| | | JPanel p = new JPanel(); |
| | | |
| | | LabelFieldDescriptor serverDescriptor = new LabelFieldDescriptor( |
| | | getMsg("upgrade-review-panel-server-label"), |
| | | getMsg("upgrade-review-panel-server-tooltip"), |
| | | LabelFieldDescriptor.FieldType.READ_ONLY, |
| | | LabelFieldDescriptor.LabelType.PRIMARY, |
| | | 0 |
| | | ); |
| | | |
| | | LabelFieldDescriptor oldVersionDescriptor = new LabelFieldDescriptor( |
| | | getMsg("upgrade-review-panel-old-version-label"), |
| | | getMsg("upgrade-review-panel-old-version-tooltip"), |
| | | LabelFieldDescriptor.FieldType.READ_ONLY, |
| | | LabelFieldDescriptor.LabelType.PRIMARY, |
| | | 0 |
| | | ); |
| | | |
| | | LabelFieldDescriptor newVersionDescriptor = new LabelFieldDescriptor( |
| | | getMsg("upgrade-review-panel-new-version-label"), |
| | | getMsg("upgrade-review-panel-new-version-tooltip"), |
| | | LabelFieldDescriptor.FieldType.READ_ONLY, |
| | | LabelFieldDescriptor.LabelType.PRIMARY, |
| | | 0 |
| | | ); |
| | | |
| | | p.setLayout(new GridBagLayout()); |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | |
| | | gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD; |
| | | gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD; |
| | | gbc.anchor = GridBagConstraints.NORTHWEST; |
| | | gbc.gridx = 0; |
| | | gbc.gridy = 0; |
| | | gbc.fill = GridBagConstraints.NONE; |
| | | p.add(UIFactory.makeJLabel(serverDescriptor), gbc); |
| | | |
| | | gbc.gridx = 1; |
| | | gbc.gridy = 0; |
| | | gbc.weightx = 1.0; |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | p.add(UIFactory.makeJTextComponent(serverDescriptor, "/xx/xx/xx"), gbc); |
| | | |
| | | gbc.gridx = 0; |
| | | gbc.gridy = 1; |
| | | gbc.fill = GridBagConstraints.NONE; |
| | | p.add(UIFactory.makeJLabel(oldVersionDescriptor), gbc); |
| | | |
| | | gbc.gridx = 1; |
| | | gbc.gridy = 1; |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | p.add(UIFactory.makeJTextComponent(oldVersionDescriptor, "abcdefg"), gbc); |
| | | |
| | | gbc.gridx = 0; |
| | | gbc.gridy = 2; |
| | | gbc.fill = GridBagConstraints.NONE; |
| | | p.add(UIFactory.makeJLabel(newVersionDescriptor), gbc); |
| | | |
| | | gbc.gridx = 1; |
| | | gbc.gridy = 2; |
| | | gbc.weighty = 1.0; |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | p.add(UIFactory.makeJTextComponent(newVersionDescriptor, "1234567"), gbc); |
| | | |
| | | return p; |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * 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 |
| | | * |
| | | * |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.quicksetup.upgrader.ui; |
| | | |
| | | import org.opends.quicksetup.ui.QuickSetupStepPanel; |
| | | import org.opends.quicksetup.ui.UIFactory; |
| | | import org.opends.quicksetup.ui.Utilities; |
| | | import org.opends.quicksetup.ui.LabelFieldDescriptor; |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.quicksetup.Installation; |
| | | import org.opends.quicksetup.event.BrowseActionListener; |
| | | import org.opends.quicksetup.upgrader.Upgrader; |
| | | |
| | | import javax.swing.*; |
| | | import javax.swing.text.JTextComponent; |
| | | import java.awt.*; |
| | | import java.util.ArrayList; |
| | | |
| | | /** |
| | | * This panel is used to show a welcome message. |
| | | */ |
| | | public class WelcomePanel extends QuickSetupStepPanel { |
| | | |
| | | private static final long serialVersionUID = 8695606871542491768L; |
| | | |
| | | /** |
| | | * Default constructor. |
| | | * @param application Upgrader application |
| | | */ |
| | | public WelcomePanel(Upgrader application) { |
| | | super(application); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected String getTitle() { |
| | | return getMsg("upgrade-welcome-panel-title"); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected String getInstructions() { |
| | | /* |
| | | * We can use org.opends.server.util.DynamicConstants without problems as it |
| | | * has been added to quicksetup.jar during build time. |
| | | */ |
| | | java.util.List<String> args = new ArrayList<String>(); |
| | | String msgKey; |
| | | if (Utils.isWebStart()) { |
| | | msgKey = "upgrade-welcome-panel-webstart-instructions"; |
| | | String cmd = Utils.isWindows() ? Installation.WINDOWS_UPGRADE_FILE_NAME : |
| | | Installation.UNIX_UPGRADE_FILE_NAME; |
| | | args.add(UIFactory.applyFontToHtml(cmd, |
| | | UIFactory.INSTRUCTIONS_MONOSPACE_FONT)); |
| | | } else { |
| | | msgKey = "upgrade-welcome-panel-offline-instructions"; |
| | | } |
| | | return getMsg(msgKey, args.toArray(new String[0])); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected Component createInputPanel() { |
| | | Component c; |
| | | |
| | | JPanel pnlBuildInfo = new JPanel(); |
| | | pnlBuildInfo.setLayout(new GridBagLayout()); |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | |
| | | // The WebStart version of this tool allows the user to |
| | | // select a build to upgrade. Running the tool from the |
| | | // command line implies a build. |
| | | if (!Utils.isWebStart()) { |
| | | |
| | | LabelFieldDescriptor serverLocationDescriptor = |
| | | new LabelFieldDescriptor(getMsg("upgrade-location-label"), |
| | | getMsg("upgrade-location-tooltip"), |
| | | LabelFieldDescriptor.FieldType.TEXTFIELD, |
| | | LabelFieldDescriptor.LabelType.PRIMARY, |
| | | UIFactory.PATH_FIELD_SIZE); |
| | | |
| | | JTextComponent tfBuild = |
| | | UIFactory.makeJTextComponent(serverLocationDescriptor, null); |
| | | |
| | | JButton butBrowse = |
| | | UIFactory.makeJButton(getMsg("browse-button-label"), |
| | | getMsg("browse-button-tooltip")); |
| | | |
| | | BrowseActionListener l = |
| | | new BrowseActionListener(tfBuild, |
| | | BrowseActionListener.BrowseType.LOCATION_DIRECTORY, |
| | | getMainWindow()); |
| | | butBrowse.addActionListener(l); |
| | | |
| | | JPanel pnlBrowser = Utilities.createBrowseButtonPanel( |
| | | UIFactory.makeJLabel(serverLocationDescriptor), |
| | | tfBuild, |
| | | butBrowse); |
| | | // pnlBrowser.setBorder(BorderFactory.createLineBorder(Color.GREEN)); |
| | | gbc.insets.top = 15; // non-standard but looks better |
| | | gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD; |
| | | gbc.anchor = GridBagConstraints.FIRST_LINE_START; |
| | | pnlBuildInfo.add(pnlBrowser, gbc); |
| | | |
| | | gbc.gridy = 1; |
| | | gbc.weighty = 1.0; |
| | | gbc.weightx = 1.0; |
| | | gbc.fill = GridBagConstraints.BOTH; |
| | | gbc.anchor = GridBagConstraints.LINE_START; |
| | | JPanel fill = new JPanel(); |
| | | // fill.setBorder(BorderFactory.createLineBorder(Color.BLUE)); |
| | | pnlBuildInfo.add(fill, gbc); |
| | | |
| | | } else { |
| | | |
| | | LabelFieldDescriptor serverLocationDescriptorRO = |
| | | new LabelFieldDescriptor(getMsg("upgrade-location-label"), |
| | | getMsg("upgrade-location-tooltip"), |
| | | LabelFieldDescriptor.FieldType.READ_ONLY, |
| | | LabelFieldDescriptor.LabelType.PRIMARY, |
| | | UIFactory.PATH_FIELD_SIZE); |
| | | |
| | | LabelFieldDescriptor serverBuildDescriptorRO = |
| | | new LabelFieldDescriptor(getMsg("upgrade-build-id-label"), |
| | | getMsg("upgrade-build-id-tooltip"), |
| | | LabelFieldDescriptor.FieldType.READ_ONLY, |
| | | LabelFieldDescriptor.LabelType.PRIMARY, |
| | | UIFactory.PATH_FIELD_SIZE); |
| | | |
| | | gbc.gridx = 0; |
| | | gbc.gridy = 0; |
| | | gbc.anchor = GridBagConstraints.FIRST_LINE_START; |
| | | gbc.insets.top = 15; // non-standard but looks better |
| | | gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD; |
| | | pnlBuildInfo.add(UIFactory.makeJLabel(serverLocationDescriptorRO), gbc); |
| | | |
| | | gbc.gridx = 1; |
| | | gbc.gridy = 0; |
| | | gbc.weightx = 1.0; |
| | | gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD; |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | gbc.anchor = GridBagConstraints.PAGE_START; |
| | | String installLocation = Utils.getPath( |
| | | getApplication().getInstallation().getRootDirectory()); |
| | | pnlBuildInfo.add( |
| | | UIFactory.makeJTextComponent( |
| | | serverLocationDescriptorRO, installLocation), gbc); |
| | | |
| | | gbc.gridx = 0; |
| | | gbc.gridy = 1; |
| | | gbc.anchor = GridBagConstraints.LINE_START; |
| | | gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD; |
| | | gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD; |
| | | pnlBuildInfo.add(UIFactory.makeJLabel(serverBuildDescriptorRO), gbc); |
| | | |
| | | gbc.gridx = 1; |
| | | gbc.gridy = 1; |
| | | gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD; |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | pnlBuildInfo.add(UIFactory.makeJTextComponent( |
| | | serverBuildDescriptorRO, |
| | | org.opends.server.util.DynamicConstants.BUILD_ID), gbc); |
| | | |
| | | gbc.gridy = 2; |
| | | gbc.weighty = 1.0; |
| | | gbc.weightx = 1.0; |
| | | gbc.fill = GridBagConstraints.BOTH; |
| | | gbc.anchor = GridBagConstraints.LINE_START; |
| | | JPanel fill = new JPanel(); |
| | | //fill.setBorder(BorderFactory.createLineBorder(Color.BLUE)); |
| | | pnlBuildInfo.add(fill, gbc); |
| | | } |
| | | |
| | | c = pnlBuildInfo; |
| | | |
| | | return c; |
| | | } |
| | | |
| | | |
| | | } |