QuickSetup.java revision 6292beaede500c125091a84263ed7cda454ba299
/*
* 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 legal-notices/CDDLv1_0.txt
* 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 legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS
*/
/**
* This class is responsible for doing the following:
* <p>
* <ul>
* <li>Check whether we are installing or uninstalling.</li>
* <li>Performs all the checks and validation of the data provided by the user
* during the setup.</li>
* <li>It will launch also the installation once the user clicks on 'Finish' if
* we are installing the product.</li>
* </ul>
*/
{
private GuiApplication application;
private CurrentInstallStatus installStatus;
private WizardStep currentStep;
private QuickSetupDialog dialog;
private ProgressDescriptor lastDescriptor;
private ProgressDescriptor descriptorToDisplay;
/** Update period of the dialogs. */
private static final int UPDATE_PERIOD = 500;
/** The full pathname of the MacOS X LaunchServices OPEN(1) helper. */
/**
* install status. This method must be called outside the event thread because
* it can perform long operations which can make the user think that the UI is
* blocked.
*
* @param args
* for the moment this parameter is not used but we keep it in order
* to (in case of need) pass parameters through the command line.
*/
{
installStatus = new CurrentInstallStatus();
{
}
else
{
}
try
{
}
catch (Throwable t)
{
// This is likely a bug.
t.printStackTrace();
}
/* In the calls to setCurrentStep the dialog will be created */
}
/**
* This method displays the setup dialog.
* This method must be called from the event thread.
*/
public void display()
{
getDialog().packAndShow();
}
/**
* ButtonActionListener implementation. It assumes that we are called in the
* event thread.
*
* @param ev
* the ButtonEvent we receive.
*/
{
switch (ev.getButtonName())
{
case NEXT:
nextClicked();
break;
case CLOSE:
closeClicked();
break;
case FINISH:
break;
case QUIT:
quitClicked();
break;
case CONTINUE_INSTALL:
break;
case PREVIOUS:
break;
case LAUNCH_STATUS_PANEL:
break;
case INPUT_PANEL_BUTTON:
break;
default:
}
}
/**
* ProgressUpdateListener implementation. Here we take the ProgressUpdateEvent
* and create a ProgressDescriptor that will be used to update the progress
* dialog.
*
* @param ev
* the ProgressUpdateEvent we receive.
* @see #runDisplayUpdater()
*/
{
synchronized (this)
{
if (isLastDescriptor)
{
}
}
}
/**
* This method is used to update the progress dialog.
* <p>
* We are receiving notifications from the installer and uninstaller (this
* class is a ProgressListener). However if we lots of notifications updating
* the progress panel every time we get a progress update can result of a lot
* 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(org.opends.quicksetup.event.ProgressUpdateEvent)
*/
private void runDisplayUpdater()
{
boolean doPool = true;
while (doPool)
{
try
{
}
synchronized (this)
{
{
if (desc != lastDisplayedDescriptor)
{
{
public void run()
{
{
}
}
});
}
}
}
}
}
/** Method called when user clicks 'Next' button of the wizard. */
private void nextClicked()
{
getDialog().workerStarted();
}
{
{
{
try
{
}
catch (UserDataException uide)
{
throw uide;
}
catch (Throwable t)
{
}
return null;
}
{
getDialog().workerFinished();
{
if (ude instanceof UserDataConfirmationException)
{
{
try
{
}
catch (Throwable t)
{
t.printStackTrace();
}
}
}
else
{
}
}
else
{
}
if (currentStep.isProgressStep())
{
launch();
}
}
};
getDialog().workerStarted();
}
/** Method called when user clicks 'Finish' button of the wizard. */
private void finishClicked()
{
{
}
}
/** Method called when user clicks 'Previous' button of the wizard. */
private void previousClicked()
{
}
/** Method called when user clicks 'Quit' button of the wizard. */
private void quitClicked()
{
}
/**
* Method called when user clicks 'Continue' button in the case where there is
* something installed.
*/
private void continueInstallClicked()
{
// TODO: move this stuff to Installer?
getDialog().forceToDisplay();
}
/** Method called when user clicks 'Close' button of the wizard. */
private void closeClicked()
{
}
private void launchStatusPanelClicked()
{
{
{
try
{
final ProcessBuilder pb;
if (isMacOS())
{
}
else
{
}
// Wait for 3 seconds. Assume that if the process has not exited everything went fine.
int returnValue = 0;
try
{
}
catch (Throwable t) {}
try
{
}
catch (IllegalThreadStateException e)
{
// The process has not exited: assume that the status panel could be launched successfully.
}
if (returnValue != 0)
{
}
}
catch (Throwable t)
{
// This looks like a bug
t.printStackTrace();
}
return null;
}
{
{
}
}
};
}
/**
* This method tries to update the visibility of the steps panel. The contents
* are updated because the user clicked in one of the buttons that could make
* the steps panel to change.
*/
private void inputPanelButtonClicked()
{
}
/**
* Method called when we want to quit the setup (for instance when the user
* clicks on 'Close' or 'Quit' buttons and has confirmed that (s)he wants to
* quit the program.
*/
public void quit()
{
flushLogs();
}
private void flushLogs()
{
{
{
h.flush();
}
}
}
/** Launch the QuickSetup application Open DS. */
public void launch()
{
{
public void run()
{
}
});
t.start();
}
/**
* Get the current step.
*
* @return the currently displayed Step of the wizard.
*/
private WizardStep getCurrentStep()
{
return currentStep;
}
/**
* Set the current step. This will basically make the required calls in the
* dialog to display the panel that corresponds to the step passed as
* argument.
*
* @param step
* The step to be displayed.
*/
{
{
throw new NullPointerException("step is null");
}
currentStep = step;
}
/**
* Get the dialog that is displayed.
*
* @return the dialog.
*/
public QuickSetupDialog getDialog()
{
{
dialog.addButtonActionListener(this);
}
return dialog;
}
/**
* Displays an error message dialog.
*
* @param msg
* the error message.
* @param title
* the title for the dialog.
*/
{
if (isCli())
{
}
else
{
}
}
/**
* Displays a confirmation message dialog.
*
* @param msg
* the confirmation message.
* @param title
* the title of the dialog.
* @return <CODE>true</CODE> if the user confirms the message, or
* <CODE>false</CODE> if not.
*/
{
}
/**
* Gets the string value for a given field name.
*
* @param fieldName
* the field name object.
* @return the string value for the field name.
*/
{
{
}
return null;
}
/**
* Gets the value for a given field name.
*
* @param fieldName
* the field name object.
* @return the value for the field name.
*/
{
}
/**
* Marks the fieldName as valid or invalid depending on the value of the
* invalid parameter. With the current implementation this implies basically
* using a red color in the label associated with the fieldName object. The
*
* @param fieldName
* the field name object.
* @param invalid
* whether to mark the field valid or invalid.
*/
{
}
/** A method to initialize the look and feel. */
private void initLookAndFeel() throws Throwable
{
}
/**
* A methods that creates an ProgressDescriptor based on the value of a
* ProgressUpdateEvent.
*
* @param ev
* the ProgressUpdateEvent used to generate the ProgressDescriptor.
* @return the ProgressDescriptor.
*/
{
if (additionalDetails != null)
{
}
/*
* Note: progressDetails might have a certain number of characters that
* break LocalizableMessage Formatter (for instance percentages).
* When fix for issue 2142 was committed it broke this code.
* So here we use LocalizableMessage.raw instead of calling directly progressDetails.toMessage
*/
return new ProgressDescriptor(status, ratio, newProgressLabel, LocalizableMessage.raw(progressDetails.toString()));
}
/**
* This is a class used when the user clicks on next and that extends
* BackgroundTask.
*/
{
private WizardStep cStep;
{
}
{
try
{
}
catch (UserDataException uide)
{
throw uide;
}
catch (Throwable t)
{
}
return null;
}
{
getDialog().workerFinished();
{
if (!(throwable instanceof UserDataException))
{
}
else
{
if (ude instanceof UserDataConfirmationException)
{
{
}
}
else if (ude instanceof UserDataCertificateException)
{
dlg.setVisible(true);
{
// Retry the click but now with the certificate accepted.
getDialog().workerStarted();
}
}
else
{
}
}
}
else
{
}
}
}
}