| | |
| | | |
| | | package org.opends.quicksetup.ui; |
| | | |
| | | import java.awt.event.ComponentListener; |
| | | import java.awt.event.WindowAdapter; |
| | | import java.awt.event.WindowEvent; |
| | | import java.util.HashSet; |
| | |
| | | private HashSet<ButtonActionListener> buttonListeners = |
| | | new HashSet<ButtonActionListener>(); |
| | | |
| | | private boolean forceToDisplaySetup; |
| | | |
| | | /** |
| | | * Constructor of QuickSetupDialog. |
| | | * @param defaultUserData the default values to be proposed to the user in |
| | |
| | | // Simulate a quit button event |
| | | notifyButtonEvent(ButtonName.QUIT); |
| | | } |
| | | } else if (isInstalled()) |
| | | } else if (isInstalled() && !forceToDisplaySetup) |
| | | { |
| | | // Simulate a close button event |
| | | notifyButtonEvent(ButtonName.CLOSE); |
| | | notifyButtonEvent(ButtonName.QUIT); |
| | | } else |
| | | { |
| | | if (getDisplayedStep() == Step.PROGRESS) |
| | |
| | | if (isUninstall()) |
| | | { |
| | | setFocusOnButton(ButtonName.FINISH); |
| | | } else if (!isInstalled()) |
| | | } else if (!isInstalled() || forceToDisplaySetup) |
| | | { |
| | | setFocusOnButton(ButtonName.NEXT); |
| | | } else |
| | | { |
| | | setFocusOnButton(ButtonName.QUIT); |
| | | if (installStatus.canOverwriteCurrentInstall()) |
| | | { |
| | | setFocusOnButton(ButtonName.CONTINUE_INSTALL); |
| | | } |
| | | else |
| | | { |
| | | setFocusOnButton(ButtonName.QUIT); |
| | | } |
| | | } |
| | | |
| | | frame.addComponentListener(new MinimumSizeComponentListener(frame, |
| | |
| | | } |
| | | |
| | | /** |
| | | * This method is called when we detected that there is something installed |
| | | * we inform of this to the user and the user wants to proceed with the |
| | | * installation destroying the contents of the data and the configuration |
| | | * in the current installation. |
| | | * |
| | | */ |
| | | public void forceToDisplaySetup() |
| | | { |
| | | forceToDisplaySetup = true; |
| | | frame.getContentPane().removeAll(); |
| | | frame.getContentPane().add(getFramePanel()); |
| | | frame.pack(); |
| | | Utils.centerOnScreen(frame); |
| | | setFocusOnButton(ButtonName.NEXT); |
| | | int minWidth = (int) frame.getPreferredSize().getWidth(); |
| | | int minHeight = (int) frame.getPreferredSize().getHeight(); |
| | | |
| | | ComponentListener[] listeners = frame.getComponentListeners(); |
| | | for (int i=0; i<listeners.length; i++) |
| | | { |
| | | if (listeners[i] instanceof MinimumSizeComponentListener) |
| | | { |
| | | frame.removeComponentListener(listeners[i]); |
| | | } |
| | | } |
| | | frame.addComponentListener(new MinimumSizeComponentListener(frame, |
| | | minWidth, minHeight)); |
| | | } |
| | | |
| | | /** |
| | | * Displays the panel corresponding to the provided step. The panel contents |
| | | * are updated with the contents of the UserInstallData object. |
| | | * @param step the step that we want to display. |
| | |
| | | setButtonEnabled(ButtonName.CLOSE, false); |
| | | break; |
| | | } |
| | | } else if (!isInstalled()) |
| | | } else if (!isInstalled() || forceToDisplaySetup) |
| | | { |
| | | // First call the panels to do the required updates on their layout |
| | | getButtonsPanel().setDisplayedStep(step); |
| | |
| | | */ |
| | | public void addButtonActionListener(ButtonActionListener l) |
| | | { |
| | | if (isUninstall()) |
| | | { |
| | | getButtonsPanel().addButtonActionListener(l); |
| | | } else if (isInstalled()) |
| | | { |
| | | getInstalledPanel().addButtonActionListener(l); |
| | | } else |
| | | { |
| | | getButtonsPanel().addButtonActionListener(l); |
| | | } |
| | | getButtonsPanel().addButtonActionListener(l); |
| | | getInstalledPanel().addButtonActionListener(l); |
| | | getButtonsPanel().addButtonActionListener(l); |
| | | getCurrentStepPanel().addButtonActionListener(l); |
| | | |
| | | buttonListeners.add(l); |
| | | } |
| | | |
| | |
| | | if (isUninstall()) |
| | | { |
| | | getButtonsPanel().removeButtonActionListener(l); |
| | | } else if (isInstalled()) |
| | | } else if (isInstalled() && !forceToDisplaySetup) |
| | | { |
| | | getInstalledPanel().removeButtonActionListener(l); |
| | | } else |
| | |
| | | getButtonsPanel()); |
| | | } |
| | | p = framePanel; |
| | | } else if (isInstalled()) |
| | | } else if (isInstalled() && !forceToDisplaySetup) |
| | | { |
| | | p = getInstalledPanel(); |
| | | } else |
| | |
| | | if (isUninstall()) |
| | | { |
| | | button = getButtonsPanel().getButton(buttonName); |
| | | } else if (isInstalled()) |
| | | } else if (isInstalled() && !forceToDisplaySetup) |
| | | { |
| | | if (buttonName == ButtonName.QUIT) |
| | | { |
| | | button = getInstalledPanel().getQuitButton(); |
| | | } else if (buttonName == ButtonName.CONTINUE_INSTALL) |
| | | { |
| | | button = getInstalledPanel().getContinueInstallButton(); |
| | | } else |
| | | { |
| | | throw new IllegalStateException("Invalid button name " + buttonName |
| | |
| | | { |
| | | if (installedPanel == null) |
| | | { |
| | | installedPanel = |
| | | new QuickSetupErrorPanel(installStatus.getInstallationMsg()); |
| | | installedPanel = new QuickSetupErrorPanel(installStatus); |
| | | } |
| | | return installedPanel; |
| | | } |