ProgressDialog.java revision a395dd575518d9e5280fc5d5d5ef47c61b174647
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * CDDL HEADER START
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * The contents of this file are subject to the terms of the
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Common Development and Distribution License, Version 1.0 only
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * (the "License"). You may not use this file except in compliance
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * with the License.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * You can obtain a copy of the license at
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * trunk/opends/resource/legal-notices/OpenDS.LICENSE
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * See the License for the specific language governing permissions
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * and limitations under the License.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * When distributing Covered Code, include this CDDL HEADER in each
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * file and include the License file at
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * add the following below this CDDL HEADER, with the fields enclosed
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * by brackets "[]" replaced with your own identifying information:
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Portions Copyright [yyyy] [name of copyright owner]
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * CDDL HEADER END
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Copyright 2008 Sun Microsystems, Inc.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterimport static org.opends.messages.QuickSetupMessages.*;
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterimport org.opends.quicksetup.event.MinimumSizeComponentListener;
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterimport org.opends.quicksetup.util.HtmlProgressMessageFormatter;
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterimport org.opends.quicksetup.util.ProgressMessageFormatter;
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * This panel is used to show the progress of the start/stop/restart operations.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster private static final long serialVersionUID = 8635080171100378470L;
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster private Message panelTitle = INFO_PROGRESS_TITLE.get();
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * ProgressDialog constructor.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * @param frame the parent frame for this dialog.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster setTitle(INFO_PROGRESS_DIALOG_TITLE.get().toString());
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Prepares size for this dialog.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster public void pack()
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * TODO: find a way to calculate this dynamically.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster addComponentListener(new MinimumSizeComponentListener(this, 500, 300));
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Returns the parent for this dialog.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * @return the parent for this dialog.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Sets the title of the panel.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * @param title the title of the panel.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Returns the title of the panel.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * @return the title of the panel
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Sets the enable state of the close button.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * @param enable whether to enable or disable the button.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster public void setCloseButtonEnabled(boolean enable)
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Sets the text in the summary label. The text can be in HTML format.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * @param text the text to be set.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Sets the text in the details text pane. The text can be in HTML format.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * @param text the text to be set.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Returns the formatter that will be used to display the messages in this
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * @return the formatter that will be used to display the messages in this
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster private ProgressMessageFormatter getFormatter()
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster formatter = new HtmlProgressMessageFormatter();
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Creates the layout of the dialog panel.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster private void createLayout()
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster /* Create title panel */
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster JPanel titlePanel = new JPanel(new GridBagLayout());
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster GridBagConstraints gbc = new GridBagConstraints();
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, title,
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster titlePanel.add(Box.createHorizontalGlue(), gbc);
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster /* Create input panel. */
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster JPanel mainPanel = new JPanel(new GridBagLayout());
ccf9d4a5c6453fa9f8b839baeee25147865fbb7dJames Phillpotts gbc.insets.top = UIFactory.TOP_INSET_INSTRUCTIONS_SUBPANEL;
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster UIFactory.makeHtmlPane(INFO_PROGRESSBAR_INITIAL_LABEL.get(),
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster gbc.insets.top = UIFactory.TOP_INSET_PROGRESS_BAR;
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster gbc.insets.bottom = UIFactory.BOTTOM_INSET_PROGRESS_BAR;
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster progressBar.setToolTipText(INFO_PROGRESSBAR_TOOLTIP.get().toString());
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster detailsTextArea = UIFactory.makeProgressPane(scroll);
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster detailsTextArea.addHyperlinkListener(new HyperlinkListener()
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster Message newText = getFormatter().getFormattedAfterUrlClick(url,
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster gbc.insets.top = UIFactory.TOP_INSET_PROGRESS_TEXTAREA;
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster /* Create buttons panel */
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster JPanel buttonsPanel = new JPanel(new GridBagLayout());
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster buttonsPanel.setBackground(UIFactory.DEFAULT_BACKGROUND);
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster buttonsPanel.add(Box.createHorizontalGlue(), gbc);
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster UIFactory.makeJButton(INFO_CLOSE_BUTTON_LABEL.get(),
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster closeButton.addActionListener(new ActionListener()
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster p1.setBackground(UIFactory.CURRENT_STEP_PANEL_BACKGROUND);
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster gbc.insets = UIFactory.getCurrentStepPanelInsets();
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster gbc.insets = UIFactory.getButtonsPanelInsets();
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Creates the progress bar panel.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * @return the created panel.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster JPanel panel = new JPanel(new GridBagLayout());
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster GridBagConstraints gbc = new GridBagConstraints();
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster // The ProgressDescriptor provides the ratio in %
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster panel.add(Box.createHorizontalStrut(UIFactory.PROGRESS_BAR_SIZE), gbc);
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster //panel.add(progressBar, gbc);
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Method written for testing purposes.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * @param args the arguments to be passed to the test program.