/*
 * DBeaver - Universal Database Manager
 * Copyright (C) 2010-2016 Serge Rieder (serge@jkiss.org)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License (version 2)
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
package org.jkiss.dbeaver.ui.dialogs;

import org.eclipse.jface.dialogs.IPageChangingListener;
import org.eclipse.jface.dialogs.PageChangingEvent;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWizard;

/**
 * NewConnectionDialog
 */
public class ActiveWizardDialog extends WizardDialog
{
    public ActiveWizardDialog(IWorkbenchWindow window, IWizard wizard)
    {
        this(window, wizard, null);
    }

    public ActiveWizardDialog(IWorkbenchWindow window, IWizard wizard, IStructuredSelection selection)
    {
        super(window.getShell(), wizard);

        // Initialize wizard
        if (wizard instanceof IWorkbenchWizard) {
            if (selection == null) {
                if (window.getSelectionService().getSelection() instanceof IStructuredSelection) {
                    selection = (IStructuredSelection)window.getSelectionService().getSelection();
                }
            }
            ((IWorkbenchWizard)wizard).init(window.getWorkbench(), selection);
        }
        addPageChangingListener(new IPageChangingListener() {
            @Override
            public void handlePageChanging(PageChangingEvent event)
            {
                if (event.getCurrentPage() instanceof ActiveWizardPage) {
                    ((ActiveWizardPage) event.getCurrentPage()).deactivatePage();
                }
//                if (event.getTargetPage() instanceof ActiveWizardPage) {
//                    ((ActiveWizardPage) event.getTargetPage()).activatePage();
//                }
            }
        });


    }

}

@@ -813,16 +813,67 @@
 ogs;%0D%0A%0D%0A
+import org.eclipse.jface.dialogs.IDialogSettings;%0D%0A
 import o
@@ -1205,31 +1205,68 @@
 d;%0D%0A
-%0D%0A/**%0D%0A * NewConnection
+import org.jkiss.dbeaver.ui.UIUtils;%0D%0A%0D%0A/**%0D%0A * ActiveWizard
 Dial
@@ -1331,16 +1331,18 @@
 log%0D%0A%7B%0D%0A
+%0D%0A
     publ
@@ -2625,11 +2625,214 @@
    %7D%0D%0A%0D%0A
+    @Override%0D%0A    protected IDialogSettings getDialogBoundsSettings()%0D%0A    %7B%0D%0A        return UIUtils.getDialogSettings(%22DBeaver.ActiveWizardDialog.%22 + getWizard().getClass().getSimpleName());%0D%0A    %7D%0D%0A%0D%0A
 %7D%0D%0A

Save wizards bounds