From f6bff1e8c31ae6ebfabfdb478771216b9773a3c4 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Thu, 24 May 2007 00:37:30 +0000
Subject: [PATCH] This commit addresses issue 1599 as well as introduces some other changes suggested by Brian after reviewing the SWAED guidelines:
---
opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties | 25 ++-
opends/src/quicksetup/org/opends/quicksetup/ui/CurrentStepPanel.java | 5
opends/src/quicksetup/org/opends/quicksetup/ButtonName.java | 4
opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupDialog.java | 15 +
opends/src/quicksetup/org/opends/quicksetup/upgrader/BuildExtractor.java | 14 +
opends/src/quicksetup/org/opends/quicksetup/ui/ButtonsPanel.java | 39 ++--
opends/src/quicksetup/org/opends/quicksetup/ui/ProgressPanel.java | 62 +++++++
opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java | 30 +--
opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java | 40 +---
opends/src/quicksetup/org/opends/quicksetup/ui/GuiApplication.java | 52 ++---
opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java | 18 -
opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupPanel.java | 18 ++
opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java | 120 ++++++--------
opends/src/quicksetup/org/opends/quicksetup/Application.java | 27 +++
14 files changed, 263 insertions(+), 206 deletions(-)
diff --git a/opends/src/quicksetup/org/opends/quicksetup/Application.java b/opends/src/quicksetup/org/opends/quicksetup/Application.java
index 4a60098..50a9701 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/Application.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/Application.java
@@ -526,6 +526,33 @@
abstract public boolean isFinished();
/**
+ * Indicates whether or not this application is capable of cancelling
+ * the operation performed in the run method. A cancellable operation
+ * should leave its environment in the same state as it was prior to
+ * running the operation (files deleted, changes backed out etc.).
+ *
+ * Marking an <code>Application</code> as cancellable may control UI
+ * elements like the presense of a cancel button while the operation
+ * is being performed.
+ *
+ * Applications marked as cancellable should override the
+ * <code>cancel</code> method in such a way as to undo whatever
+ * actions have taken place in the run method up to that point.
+ *
+ * @return boolean where true inidcates that the operation is cancellable
+ */
+ abstract public boolean isCancellable();
+
+ /**
+ * Signals that the application should cancel a currently running
+ * operation as soon as possible and return the environment to the
+ * state prior to running the operation. When finished backing
+ * out changes the application should make sure that <code>isFinished</code>
+ * returns true so that the application can complete.
+ */
+ abstract public void cancel();
+
+ /**
* 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
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ButtonName.java b/opends/src/quicksetup/org/opends/quicksetup/ButtonName.java
index e11df2e..4ef471a 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ButtonName.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ButtonName.java
@@ -58,10 +58,6 @@
*/
FINISH,
/**
- * The Cancel button.
- */
- CANCEL,
- /**
* The Launch Status Panel button.
*/
LAUNCH_STATUS_PANEL
diff --git a/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java b/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
index 0869d69..34b3097 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
@@ -152,6 +152,13 @@
/**
* {@inheritDoc}
*/
+ public boolean isCancellable() {
+ return false; // TODO: have installer delete installed files upon cancel
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public UserData createUserData() {
UserData ud = new UserData();
ud.setServerLocation(Utils.getDefaultServerLocation());
@@ -198,20 +205,6 @@
/**
* {@inheritDoc}
*/
- public boolean canClose(WizardStep step) {
- return step == PROGRESS;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean canCancel(WizardStep step) {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
public boolean isSubStep(WizardStep step)
{
return SUBSTEPS.contains(step);
@@ -321,8 +314,8 @@
/**
* {@inheritDoc}
*/
- public void cancelClicked(WizardStep cStep, QuickSetup qs) {
- // do nothing;
+ public void cancel() {
+ // do nothing; not cancellable
}
/**
@@ -489,16 +482,11 @@
if (step == REVIEW) {
dlg.setFocusOnButton(ButtonName.FINISH);
dlg.setDefaultButton(ButtonName.FINISH);
- } else if (step == PROGRESS) {
- dlg.setDefaultButton(ButtonName.CLOSE);
} else if (step == WELCOME) {
dlg.setDefaultButton(ButtonName.NEXT);
dlg.setFocusOnButton(ButtonName.NEXT);
} else if (step == REVIEW) {
dlg.setDefaultButton(ButtonName.NEXT);
- } else if (step == PROGRESS) {
- dlg.setFocusOnButton(ButtonName.CLOSE);
- dlg.setButtonEnabled(ButtonName.CLOSE, false);
} else {
dlg.setDefaultButton(ButtonName.NEXT);
}
diff --git a/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties b/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
index e2716e6..27ef222 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
+++ b/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
@@ -215,6 +215,7 @@
quit-button-install-tooltip=Quit Setup
quit-button-upgrade-tooltip=Quit Upgrade
cancel-button-label=Cancel
+cancel-button-tooltip=Cancel the currently running operation
cancel-button-uninstall-tooltip=Cancel Uninstall
shutdown-button-label=Shutdown
continue-button-label=Continue
@@ -227,14 +228,14 @@
confirm-close-install-title=Confirmation Required
confirm-close-install-msg=OpenDS QuickSetup has not yet completed.\nAre you \
sure you want to close the QuickSetup Window?
-confirm-quit-install-title=Confirmation Required
-confirm-quit-install-msg=Are you sure you want to quit OpenDS \
+confirm-cancel-install-title=Confirmation Required
+confirm-cancel-install-msg=Are you sure you want to cancel OpenDS \
QuickSetup?\nIf you click 'Yes' nothing will be installed on your system.
confirm-close-uninstall-title=Confirmation Required
confirm-close-uninstall-msg=OpenDS Uninstall has not yet completed.\nAre you \
sure you want to close the Uninstall Window?
-confirm-close-upgrade-title=Confirmation Required
-confirm-close-upgrade-msg=OpenDS QuickUpgrade has not yet completed.\nIf you \
+confirm-cancel-upgrade-title=Confirmation Required
+confirm-cancel-upgrade-msg=OpenDS QuickUpgrade has not yet completed.\nIf you \
click 'Yes' any changes that have been\nmade to the server being upgraded \
will\nbe backed out.\n\nAre you sure you want to close the QuickUpgrade Window?\n
confirm-quit-upgrade-title=Confirmation Required
@@ -250,6 +251,8 @@
the server for you and continue with the uninstall? If you click\n\
No, you will need to stop the server manually to continue.
confirm-uninstall-server-running-title=Server is Running
+confirm-cancel-title=Confirmation Required
+confirm-cancel-prompt=Cancel the running operation?
#
@@ -820,7 +823,7 @@
summary-upgrade-abort=Canceling Upgrade...
summary-upgrade-finished-successfully=<b>OpenDS QuickUpgrade Completed \
Successfully.</b><br>The OpenDS installation at {0} has now been upgraded \
- to version {1}.
+ to version {1}.<br><br><INPUT type="submit" value="Launch Status Panel"></INPUT>
summary-upgrade-finished-successfully-cli=OpenDS QuickUpgrade Completed \
Successfully. The OpenDS installation at {0} has now been upgraded \
to version {1}.
@@ -828,7 +831,7 @@
The upgrade operation could not complete successfully due to errors and \
the installation has been restored to the state it was in before the upgrade \
operation. See the 'Details' text for more information on why the upgrade \
- operation failed.
+ operation failed.<br><br><INPUT type="submit" value="Launch Status Panel"></INPUT>
summary-upgrade-finished-with-errors-cli=OpenDS QuickUpgrade Failed. \
The upgrade operation could not complete successfully due to errors and \
the installation has been restored to the state it was in before the upgrade \
@@ -836,12 +839,18 @@
summary-upgrade-finished-with-warnings=<b>OpenDS QuickUpgrade Succeeded With \
Warnings</b><br>The upgrade operation completed successfully but the upgrader \
had problems that require attention. See the 'Details' text for more \
- information on the problems.
+ information on the problems.<br><br><INPUT type="submit" value="Launch Status Panel"></INPUT>
summary-upgrade-finished-with-warnings-cli=OpenDS QuickUpgrade Succeeded With \
Warnings. The upgrade operation completed successfully but the upgrader \
had problems that require attention. See the logs for details on the \
problems.
-
+summary-upgrade-finished-canceled=<b>OpenDS QuickUpgrade Canceled.</b> \
+ <br>The upgrade operation was canceled and the installation has been \
+ restored to the state it was in before the upgrade operation.\
+ <br><br><INPUT type="submit" value="Launch Status Panel"></INPUT>
+summary-upgrade-finished-canceled-cli=<b>OpenDS QuickUpgrade Canceled. \
+ The upgrade operation was canceled and the installation has been \
+ restored to the state it was in before the upgrade operation.
#
# Progress messages
#
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/ButtonsPanel.java b/opends/src/quicksetup/org/opends/quicksetup/ui/ButtonsPanel.java
index 3c213bb..dd57fc9 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/ButtonsPanel.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/ButtonsPanel.java
@@ -64,8 +64,6 @@
private JButton finishButton;
- private JButton cancelButton;
-
/**
* Default constructor.
* @param application Application running in QuickSetup
@@ -103,7 +101,7 @@
*
* @param step the step in the wizard.
*/
- public void setDisplayedStep(WizardStep step)
+ public void updateButtons(WizardStep step)
{
GuiApplication application = getApplication();
previousButton.setVisible(application.canGoBack(step));
@@ -114,9 +112,15 @@
finishButton.setVisible(false);
nextButton.setVisible(application.canGoForward(step));
}
- quitButton.setVisible(application.canQuit(step));
- closeButton.setVisible(application.canClose(step));
- cancelButton.setVisible(application.canCancel(step));
+
+ // The quit button appears on all the panels leading up
+ // to the progress panel
+ quitButton.setVisible(!step.isProgressStep());
+
+ // The close button is only used on the progress panel and
+ // is only enabled once progress has finished or cancelled.
+ closeButton.setVisible(step.isProgressStep());
+ closeButton.setEnabled(application.getCurrentProgressStep().isLast());
}
/**
@@ -149,10 +153,6 @@
b = finishButton;
break;
- case CANCEL:
- b = cancelButton;
- break;
-
default:
throw new IllegalArgumentException("Unknown button name: " +
buttonName);
@@ -191,9 +191,6 @@
tooltip = application.getFinishButtonToolTipKey();
finishButton = createButton(label, tooltip, ButtonName.FINISH);
- cancelButton =
- createButton("cancel-button-label", "cancel-button-uninstall-tooltip",
- ButtonName.CANCEL);
}
/**
@@ -263,21 +260,19 @@
gbc.weightx = 0.0;
gbc.fill = GridBagConstraints.NONE;
gbc.insets.left = 0;
- JPanel quitCloseCancelPanel = new JPanel(new GridBagLayout());
+ JPanel quitClosePanel = new JPanel(new GridBagLayout());
// Set as opaque to inherit the background color of ButtonsPanel
- quitCloseCancelPanel.setOpaque(false);
- quitCloseCancelPanel.add(
+ quitClosePanel.setOpaque(false);
+ quitClosePanel.add(
Box.createHorizontalStrut(UIFactory.HORIZONTAL_INSET_BETWEEN_BUTTONS),
gbcAux);
- quitCloseCancelPanel.add(quitButton, gbcAux);
- quitCloseCancelPanel.add(closeButton, gbcAux);
- quitCloseCancelPanel.add(cancelButton, gbcAux);
+ quitClosePanel.add(quitButton, gbcAux);
+ quitClosePanel.add(closeButton, gbcAux);
width =
(int) Math.max(quitButton.getPreferredSize().getWidth(), closeButton
.getPreferredSize().getWidth());
- width = (int) Math.max(width, cancelButton.getPreferredSize().getWidth());
- quitCloseCancelPanel.add(Box.createHorizontalStrut(width), gbcAux);
- add(quitCloseCancelPanel, gbc);
+ quitClosePanel.add(Box.createHorizontalStrut(width), gbcAux);
+ add(quitClosePanel, gbc);
}
/**
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/CurrentStepPanel.java b/opends/src/quicksetup/org/opends/quicksetup/ui/CurrentStepPanel.java
index 189cdaa..3f0b88e 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/CurrentStepPanel.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/CurrentStepPanel.java
@@ -62,10 +62,12 @@
/**
* The constructor of this class.
* @param app Application used to create panels for populating the layout
+ * @param qs QuickSetup acting as controller
*/
- public CurrentStepPanel(GuiApplication app)
+ public CurrentStepPanel(GuiApplication app, QuickSetup qs)
{
super(app);
+ setQuickSetup(qs);
createLayout(app);
}
@@ -125,6 +127,7 @@
for (WizardStep step : steps) {
QuickSetupStepPanel panel = app.createWizardStepPanel(step);
if (panel != null) {
+ panel.setQuickSetup(getQuickSetup());
panel.initialize();
hmPanels.put(step, panel);
}
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/GuiApplication.java b/opends/src/quicksetup/org/opends/quicksetup/ui/GuiApplication.java
index 1a0c203..e3f15d4 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/GuiApplication.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/GuiApplication.java
@@ -140,6 +140,19 @@
}
/**
+ * Called before the application cancels its operation, giving the
+ * user a chance to confirm the cancellation action.
+ * @param qs QuickSetup that can be used for confirming
+ * @return boolean where true indicates that the user answered
+ * affirmatively to the cancelation confirmation
+ */
+ public boolean confirmCancel(QuickSetup qs) {
+ return qs.displayConfirmation(
+ getMsg("confirm-cancel-prompt"),
+ getMsg("confirm-cancel-title"));
+ }
+
+ /**
* Get the name of the button that will receive initial focus.
* @return ButtonName of the button to receive initial focus
*/
@@ -184,6 +197,14 @@
abstract public WizardStep getPreviousWizardStep(WizardStep step);
/**
+ * Gets the currently displayed wizard step.
+ * @return WizardStep being displayed.
+ */
+ public WizardStep getCurrentWizardStep() {
+ return displayedStep;
+ }
+
+ /**
* Indicates whether or not the provided <code>step</code> is a sub step or
* not.
* @param step WizardStep for which the return value indicates whether
@@ -276,28 +297,6 @@
}
/**
- * Inidicates whether or not the user is allowed to close the wizard from
- * <code>step</code>.
- * @param step WizardStep for which the the return value indicates whether
- * or not the user can close the wizard
- * @return boolean where true indicates the user can close the wizard
- */
- public boolean canClose(WizardStep step) {
- return false;
- }
-
- /**
- * Inidicates whether or not the user is allowed to cancel the wizard from
- * <code>step</code>.
- * @param step WizardStep for which the the return value indicates whether
- * or not the user can cancel the wizard
- * @return boolean where true indicates the user can cancel the wizard
- */
- public boolean canCancel(WizardStep step) {
- return false;
- }
-
- /**
* Called when the user has clicked the 'previous' button.
* @param cStep WizardStep at which the user clicked the previous button
* @param qs QuickSetup controller
@@ -333,15 +332,6 @@
}
/**
- * Called when the user has clicked the 'cancel' button.
- * @param cStep WizardStep at which the user clicked the cancel button
- * @param qs QuickSetup controller
- */
- public void cancelClicked(WizardStep cStep, QuickSetup qs) {
- qs.quit();
- }
-
- /**
* Called when the user has clicked the 'quit' button.
* @param step WizardStep at which the user clicked the quit button
* @param qs QuickSetup controller
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/ProgressPanel.java b/opends/src/quicksetup/org/opends/quicksetup/ui/ProgressPanel.java
index 1743dbe..13d8c4b 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/ProgressPanel.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/ProgressPanel.java
@@ -33,12 +33,7 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import javax.swing.Box;
-import javax.swing.JEditorPane;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JProgressBar;
-import javax.swing.JScrollPane;
+import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
@@ -59,6 +54,8 @@
private JProgressBar progressBar;
+ private JButton btnCancel;
+
private JEditorPane detailsTextArea;
private String lastText;
@@ -178,6 +175,7 @@
if (status.isLast()) {
progressBar.setVisible(false);
+ btnCancel.setVisible(false);
if (!status.isError()) {
summaryText = "<form>"+summaryText+"</form>";
}
@@ -206,6 +204,20 @@
gbc.insets = UIFactory.getEmptyInsets();
gbc.fill = GridBagConstraints.HORIZONTAL;
+ btnCancel = UIFactory.makeJButton(
+ getMsg("cancel-button-label"),
+ getMsg("cancel-button-tooltip"));
+ btnCancel.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ GuiApplication app = getApplication();
+ QuickSetup qs = getQuickSetup();
+ if (app.confirmCancel(qs)) {
+ app.cancel();
+ btnCancel.setEnabled(false);
+ }
+ }
+ });
+
progressBar = new JProgressBar();
progressBar.setIndeterminate(true);
// The ProgressDescriptor provides the ratio in %
@@ -221,10 +233,48 @@
gbc.gridwidth = GridBagConstraints.RELATIVE;
gbc.weightx = 0.0;
panel.add(progressBar, gbc);
+
+ if (getApplication().isCancellable()) {
+ gbc.insets.left = 15;
+ gbc.fill = GridBagConstraints.NONE;
+ gbc.anchor = GridBagConstraints.LINE_START;
+ gbc.gridwidth = 1;
+ panel.add(btnCancel, gbc);
+ }
+
gbc.gridwidth = GridBagConstraints.REMAINDER;
+ gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 1.0;
panel.add(Box.createHorizontalGlue(), gbc);
+
+
return panel;
}
+
+// public static void main(String[] args) {
+// final UserData ud = new UpgradeUserData();
+// ud.setServerLocation("XXX/XXXXX/XX/XXXXXXXXXXXX/XXXX");
+// Upgrader app = new Upgrader();
+// app.setUserData(ud);
+// final ProgressPanel p = new ProgressPanel(app);
+// p.initialize();
+// JFrame frame = new JFrame();
+// frame.getContentPane().add(p);
+// frame.addComponentListener(new ComponentAdapter() {
+// public void componentHidden(ComponentEvent componentEvent) {
+// System.exit(0);
+// }
+// });
+// frame.pack();
+// frame.setVisible(true);
+// new Thread(new Runnable() {
+// public void run() {
+// p.beginDisplay(ud);
+// }
+// }).start();
+//
+// }
+
+
}
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java b/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java
index 78e6492..37194ad 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java
@@ -172,10 +172,6 @@
previousClicked();
break;
- case CANCEL:
- cancelClicked();
- break;
-
case LAUNCH_STATUS_PANEL:
launchStatusPanelClicked();
break;
@@ -362,16 +358,6 @@
application.closeClicked(cStep, this);
}
- /**
- * Method called when user clicks 'Cancel' button of the wizard.
- *
- */
- private void cancelClicked()
- {
- WizardStep cStep = getCurrentStep();
- application.cancelClicked(cStep, this);
- }
-
private void launchStatusPanelClicked()
{
BackgroundTask worker = new BackgroundTask()
@@ -460,6 +446,8 @@
public void run()
{
runDisplayUpdater();
+ WizardStep ws = application.getCurrentWizardStep();
+ getDialog().getButtonsPanel().updateButtons(ws);
}
});
t.start();
@@ -531,7 +519,7 @@
if (dialog == null)
{
dialog = new QuickSetupDialog(application,
- installStatus);
+ installStatus, this);
dialog.addButtonActionListener(this);
}
return dialog;
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupDialog.java b/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupDialog.java
index 410ad11..6f40872 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupDialog.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupDialog.java
@@ -85,22 +85,26 @@
private GuiApplication application;
+ private QuickSetup quickSetup;
+
private boolean forceToDisplay;
/**
* Constructor of QuickSetupDialog.
* @param app Application to run in as a wizard
* @param installStatus of the current environment
+ * @param qs QuickSetup acting as controller
*/
public QuickSetupDialog(GuiApplication app,
- CurrentInstallStatus installStatus)
+ CurrentInstallStatus installStatus,
+ QuickSetup qs)
{
if (app == null) {
throw new IllegalArgumentException("application cannot be null");
}
this.application = app;
this.installStatus = installStatus;
-
+ this.quickSetup = qs;
frame = new JFrame(application.getFrameTitle());
frame.getContentPane().add(getFramePanel());
frame.addWindowListener(new WindowAdapter() {
@@ -176,7 +180,7 @@
{
displayedStep = step;
// First call the panels to do the required updates on their layout
- getButtonsPanel().setDisplayedStep(step);
+ getButtonsPanel().updateButtons(step);
getStepsPanel().setDisplayedStep(step, userData);
getCurrentStepPanel().setDisplayedStep(step, userData);
}
@@ -393,6 +397,7 @@
if (stepsPanel == null)
{
stepsPanel = new StepsPanel(application);
+ stepsPanel.setQuickSetup(quickSetup);
}
return stepsPanel;
}
@@ -405,7 +410,7 @@
{
if (currentStepPanel == null)
{
- currentStepPanel = new CurrentStepPanel(application);
+ currentStepPanel = new CurrentStepPanel(application, quickSetup);
}
return currentStepPanel;
}
@@ -420,6 +425,7 @@
if (buttonsPanel == null)
{
buttonsPanel = new ButtonsPanel(application);
+ buttonsPanel.setQuickSetup(quickSetup);
}
return buttonsPanel;
}
@@ -519,6 +525,7 @@
installedPanel = new QuickSetupErrorPanel(
application,
installStatus);
+ installedPanel.setQuickSetup(quickSetup);
}
return installedPanel;
}
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupPanel.java b/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupPanel.java
index d2872bb..c63745a 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupPanel.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupPanel.java
@@ -46,6 +46,8 @@
private GuiApplication application;
+ private QuickSetup quickSetup;
+
/**
* The basic constructor to be called by the subclasses.
* @param application Application this panel represents
@@ -58,6 +60,22 @@
}
/**
+ * Sets the instance of <code>QuickSetup</code> acting as controller.
+ * @param qs QuickSetup instance
+ */
+ void setQuickSetup(QuickSetup qs) {
+ this.quickSetup = qs;
+ }
+
+ /**
+ * Gets the instance of <code>QuickSetup</code> acting as controller.
+ * @return QuickSetup instance
+ */
+ protected QuickSetup getQuickSetup() {
+ return this.quickSetup;
+ }
+
+ /**
* Returns the frame or window containing this panel.
* @return the frame or window containing this panel.
*/
diff --git a/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java b/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java
index d6f8775..cc88ab1 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java
@@ -131,20 +131,6 @@
* {@inheritDoc}
*/
public boolean canQuit(WizardStep step) {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean canClose(WizardStep step) {
- return step == Step.PROGRESS;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean canCancel(WizardStep step) {
return step == Step.CONFIRM_UNINSTALL;
}
@@ -178,18 +164,6 @@
}
/**
- * {@inheritDoc}
- */
- public void cancelClicked(WizardStep cStep, QuickSetup qs) {
- if (cStep == Step.CONFIRM_UNINSTALL) {
- qs.quit();
- } else {
- throw new IllegalStateException(
- "Cancel only can be clicked on CONFIRM_UNINSTALL step");
- }
- }
-
- /**
* Update the UserData object according to the content of the review
* panel.
*/
@@ -633,6 +607,20 @@
/**
* {@inheritDoc}
*/
+ public boolean isCancellable() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void cancel() {
+ // do nothing; not cancellable
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public void windowClosing(QuickSetupDialog dlg, WindowEvent evt) {
if (dlg.getDisplayedStep() == Step.PROGRESS) {
// Simulate a close button event
diff --git a/opends/src/quicksetup/org/opends/quicksetup/upgrader/BuildExtractor.java b/opends/src/quicksetup/org/opends/quicksetup/upgrader/BuildExtractor.java
index 7e5d0ef..2d9b281 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/upgrader/BuildExtractor.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/upgrader/BuildExtractor.java
@@ -205,4 +205,18 @@
public boolean isFinished() {
return finished;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isCancellable() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void cancel() {
+ // do nothing; not cancellable
+ }
}
diff --git a/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java b/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
index 0bfb343..0f73c50 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
@@ -169,6 +169,8 @@
FINISHED_WITH_WARNINGS("summary-upgrade-finished-with-warnings", 100),
+ FINISHED_CANCELED("summary-upgrade-finished-canceled", 100),
+
FINISHED("summary-upgrade-finished-successfully", 100);
private String summaryMsgKey;
@@ -202,7 +204,8 @@
public boolean isLast() {
return this == FINISHED ||
this == FINISHED_WITH_ERRORS ||
- this == FINISHED_WITH_WARNINGS;
+ this == FINISHED_WITH_WARNINGS ||
+ this == FINISHED_CANCELED;
}
/**
@@ -442,6 +445,8 @@
String txt = null;
if (step == UpgradeProgressStep.FINISHED) {
txt = getFinalSuccessMessage();
+ } else if (step == UpgradeProgressStep.FINISHED_CANCELED) {
+ txt = getFinalCanceledMessage();
} else if (step == UpgradeProgressStep.FINISHED_WITH_ERRORS) {
txt = getFinalErrorMessage();
} else if (step == UpgradeProgressStep.FINISHED_WITH_WARNINGS) {
@@ -527,13 +532,6 @@
/**
* {@inheritDoc}
*/
- public boolean canClose(WizardStep step) {
- return step == UpgradeWizardStep.PROGRESS;
- }
-
- /**
- * {@inheritDoc}
- */
public String getFinishButtonToolTipKey() {
return "finish-button-upgrade-tooltip";
}
@@ -548,33 +546,23 @@
/**
* {@inheritDoc}
*/
- public void closeClicked(WizardStep cStep, final QuickSetup qs) {
- if (cStep == UpgradeWizardStep.PROGRESS) {
- if (isFinished()) {
- qs.quit();
- } else if (qs.displayConfirmation(getMsg("confirm-close-upgrade-msg"),
- getMsg("confirm-close-upgrade-title"))) {
- abort = true;
- JButton btnClose = qs.getDialog().getButtonsPanel().
- getButton(ButtonName.CLOSE);
- btnClose.setEnabled(false);
- new Thread(new Runnable() {
- public void run() {
- while (!isFinished()) {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- // do nothing
- }
- }
- qs.quit();
- }
- }).start();
- }
- } else {
- throw new IllegalStateException(
- "Close only can be clicked on PROGRESS step");
- }
+ public void cancel() {
+
+ // The run() method checks that status of this variable
+ // occasionally and aborts the operation if it discovers
+ // a 'true' value.
+ abort = true;
+
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean confirmCancel(QuickSetup qs) {
+ return qs.displayConfirmation(
+ getMsg("confirm-cancel-upgrade-msg"),
+ getMsg("confirm-cancel-upgrade-title"));
}
/**
@@ -592,6 +580,13 @@
/**
* {@inheritDoc}
*/
+ public boolean isCancellable() {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public void quitClicked(WizardStep cStep, final QuickSetup qs) {
if (cStep == UpgradeWizardStep.PROGRESS) {
throw new IllegalStateException(
@@ -1076,7 +1071,16 @@
// skipped because the process has already exited by the time
// processing messages has finished. Need to resolve these
// issues.
- if (runError != null) {
+ if (abort) {
+ LOG.log(Level.INFO, "upgrade canceled by user");
+ if (!Utils.isCli()) {
+ notifyListenersOfLog();
+ this.currentProgressStep = UpgradeProgressStep.FINISHED_CANCELED;
+ notifyListeners(null);
+ } else {
+ setCurrentProgressStep(UpgradeProgressStep.FINISHED_CANCELED);
+ }
+ } else if (runError != null) {
LOG.log(Level.INFO, "upgrade completed with errors", runError);
if (!Utils.isCli()) {
notifyListenersOfLog();
@@ -1120,38 +1124,7 @@
private void checkAbort() throws ApplicationException {
if (abort) throw new ApplicationException(
ApplicationException.Type.APPLICATION,
- "upgrade canceled by user", null);
- }
-
- /**
- * Stops and starts the server checking for serious errors. Also
- * has the side effect of having the server write schema.current
- * if it has never done so.
- */
- private void checkServerHealth() throws ApplicationException {
- Installation installation = getInstallation();
- ServerHealthChecker healthChecker = new ServerHealthChecker(installation);
- try {
- healthChecker.checkServer();
- List<String> problems = healthChecker.getProblemMessages();
- if (problems != null && problems.size() > 0) {
- throw new ApplicationException(
- ApplicationException.Type.APPLICATION,
- "The server currently starts with errors which must " +
- "be resolved before an upgrade can occur: \n\n" +
- Utils.listToString(problems, "\n\n"),
- null);
- }
- } catch (Exception e) {
- if (e instanceof ApplicationException) {
- throw (ApplicationException)e;
- } else {
- throw new ApplicationException(ApplicationException.Type.APPLICATION,
- "Server health check failed. Please resolve the following " +
- "before running the upgrade " +
- "tool: " + e.getLocalizedMessage(), e);
- }
- }
+ "Upgrade canceled", null);
}
/**
@@ -1616,6 +1589,17 @@
return txt;
}
+ private String getFinalCanceledMessage() {
+ String txt;
+ if (Utils.isCli()) {
+ txt = getMsg("summary-upgrade-finished-canceled-cli");
+ } else {
+ txt = getFormattedSuccess(
+ getMsg("summary-upgrade-finished-canceled"));
+ }
+ return txt;
+ }
+
private String getFinalErrorMessage() {
String txt;
if (Utils.isCli()) {
--
Gitblit v1.10.0