Search in sources :

Example 6 with WizardFragment

use of org.eclipse.wst.server.ui.wizard.WizardFragment in project webtools.servertools by eclipse.

the class TaskWizard method addSubWizardFragments.

private void addSubWizardFragments(WizardFragment fragment, List<WizardFragment> list) {
    Iterator iterator = fragment.getChildFragments().iterator();
    while (iterator.hasNext()) {
        WizardFragment child = (WizardFragment) iterator.next();
        list.add(child);
        addSubWizardFragments(child, list);
    }
}
Also used : DownloadableAdapterLicenseWizardFragment(org.eclipse.wst.server.ui.internal.wizard.fragment.DownloadableAdapterLicenseWizardFragment) WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment)

Example 7 with WizardFragment

use of org.eclipse.wst.server.ui.wizard.WizardFragment in project webtools.servertools by eclipse.

the class TaskWizard method switchWizardFragment.

protected void switchWizardFragment(WizardFragment newFragment) {
    List list = getAllWizardFragments();
    int oldIndex = list.indexOf(currentFragment);
    int newIndex = list.indexOf(newFragment);
    if (oldIndex == newIndex)
        return;
    // safeExecuteTask(currentFragment, DEPARTURE);
    if (currentFragment != null)
        currentFragment.exit();
    if (oldIndex < newIndex)
        oldIndex++;
    else
        oldIndex--;
    while (oldIndex != newIndex) {
        WizardFragment fragment = (WizardFragment) list.get(oldIndex);
        // safeExecuteTask(fragment, ARRIVAL);
        // safeExecuteTask(fragment, DEPARTURE);
        fragment.enter();
        fragment.exit();
        if (oldIndex < newIndex)
            oldIndex++;
        else
            oldIndex--;
    }
    currentFragment = newFragment;
    // safeExecuteTask(currentFragment, ARRIVAL);
    currentFragment.enter();
}
Also used : DownloadableAdapterLicenseWizardFragment(org.eclipse.wst.server.ui.internal.wizard.fragment.DownloadableAdapterLicenseWizardFragment) WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment)

Example 8 with WizardFragment

use of org.eclipse.wst.server.ui.wizard.WizardFragment in project webtools.servertools by eclipse.

the class TaskWizard method performFinish.

public boolean performFinish() {
    if (currentFragment != null)
        currentFragment.exit();
    final WizardFragment cFragment = currentFragment;
    final List list = getAllWizardFragments();
    IWorkspaceRunnable runnable = new IWorkspaceRunnable() {

        public void run(IProgressMonitor monitor) throws CoreException {
            // enter & exit the remaining pages
            int index = list.indexOf(cFragment);
            while (index > 0 && index < list.size() - 1) {
                final WizardFragment fragment = (WizardFragment) list.get(++index);
                try {
                    Display.getDefault().syncExec(new Runnable() {

                        public void run() {
                            fragment.enter();
                            fragment.exit();
                        }
                    });
                } catch (Exception e) {
                    if (Trace.WARNING) {
                        Trace.trace(Trace.STRING_WARNING, "Could not enter/exit page", e);
                    }
                }
            }
            if (useJob()) {
                class FinishWizardJob extends Job {

                    public FinishWizardJob() {
                        super(getJobTitle());
                    }

                    public boolean belongsTo(Object family) {
                        return "org.eclipse.wst.server.ui.family".equals(family);
                    }

                    public IStatus run(IProgressMonitor monitor2) {
                        try {
                            Iterator iterator = list.iterator();
                            while (iterator.hasNext()) executeTask((WizardFragment) iterator.next(), FINISH, monitor2);
                        } catch (CoreException ce) {
                            if (Trace.SEVERE) {
                                Trace.trace(Trace.STRING_SEVERE, "Error finishing wizard job", ce);
                            }
                            return new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, 0, ce.getLocalizedMessage(), null);
                        }
                        return Status.OK_STATUS;
                    }
                }
                FinishWizardJob job = new FinishWizardJob();
                job.setUser(true);
                job.schedule();
            } else {
                Iterator iterator = list.iterator();
                while (iterator.hasNext()) executeTask((WizardFragment) iterator.next(), FINISH, monitor);
            }
        }
    };
    Throwable t = null;
    try {
        if (getContainer() != null)
            getContainer().run(true, true, new WorkspaceRunnableAdapter(runnable));
        else
            runnable.run(new NullProgressMonitor());
        return true;
    } catch (InvocationTargetException te) {
        if (Trace.SEVERE) {
            Trace.trace(Trace.STRING_SEVERE, "Error finishing task wizard", te);
        }
        t = te.getCause();
    } catch (InterruptedException interruptedEx) {
        if (Trace.INFO) {
            Trace.trace(Trace.STRING_INFO, "The task wizard was cancelled.", interruptedEx);
        }
        // return false since the request was canceled
        return false;
    } catch (Exception e) {
        if (Trace.SEVERE) {
            Trace.trace(Trace.STRING_SEVERE, "Error finishing task wizard 2", e);
        }
        t = e;
    }
    if (Trace.WARNING) {
        Trace.trace(Trace.STRING_WARNING, "Error completing wizard", t);
    }
    if (t instanceof CoreException) {
        EclipseUtil.openError(t.getLocalizedMessage(), ((CoreException) t).getStatus());
    } else if (t instanceof NullPointerException)
        EclipseUtil.openError("NullPointerException");
    else
        EclipseUtil.openError(t.getLocalizedMessage());
    return false;
}
Also used : DownloadableAdapterLicenseWizardFragment(org.eclipse.wst.server.ui.internal.wizard.fragment.DownloadableAdapterLicenseWizardFragment) WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) WorkspaceRunnableAdapter(org.eclipse.wst.server.ui.internal.wizard.page.WorkspaceRunnableAdapter) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) Job(org.eclipse.core.runtime.jobs.Job)

Example 9 with WizardFragment

use of org.eclipse.wst.server.ui.wizard.WizardFragment in project webtools.servertools by eclipse.

the class TaskWizard method getAllWizardFragments.

private List<WizardFragment> getAllWizardFragments() {
    List<WizardFragment> list = new ArrayList<WizardFragment>();
    list.add(rootFragment);
    addSubWizardFragments(rootFragment, list);
    Iterator iterator = list.iterator();
    while (iterator.hasNext()) {
        WizardFragment fragment = (WizardFragment) iterator.next();
        if ((!(fragment instanceof DownloadableAdapterLicenseWizardFragment)) && !taskModel.equals(fragment.getTaskModel()))
            fragment.setTaskModel(taskModel);
    }
    return list;
}
Also used : DownloadableAdapterLicenseWizardFragment(org.eclipse.wst.server.ui.internal.wizard.fragment.DownloadableAdapterLicenseWizardFragment) WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment) DownloadableAdapterLicenseWizardFragment(org.eclipse.wst.server.ui.internal.wizard.fragment.DownloadableAdapterLicenseWizardFragment)

Example 10 with WizardFragment

use of org.eclipse.wst.server.ui.wizard.WizardFragment in project webtools.servertools by eclipse.

the class TaskWizard method addPages.

/* (non-Javadoc)
	 * @see org.eclipse.jface.wizard.IWizard#addPages()
	 */
public void addPages() {
    if (addingPages)
        return;
    try {
        addingPages = true;
        pages = new ArrayList<IWizardPage>();
        Iterator<WizardFragment> iterator = getAllWizardFragments().iterator();
        while (iterator.hasNext()) {
            WizardFragment fragment = iterator.next();
            TaskWizardPage page = getFragmentData(fragment);
            if (fragment.hasComposite()) {
                if (page != null)
                    addPage(page);
                else {
                    TaskWizardPage page2 = new TaskWizardPage(fragment);
                    fragmentData.put(fragment, page2);
                    addPage(page2);
                }
            }
        }
    } catch (Exception e) {
        if (Trace.SEVERE) {
            Trace.trace(Trace.STRING_SEVERE, "Error adding fragments to wizard", e);
        }
    } finally {
        addingPages = false;
    }
}
Also used : DownloadableAdapterLicenseWizardFragment(org.eclipse.wst.server.ui.internal.wizard.fragment.DownloadableAdapterLicenseWizardFragment) WizardFragment(org.eclipse.wst.server.ui.wizard.WizardFragment) IWizardPage(org.eclipse.jface.wizard.IWizardPage) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

WizardFragment (org.eclipse.wst.server.ui.wizard.WizardFragment)22 WizardDialog (org.eclipse.jface.wizard.WizardDialog)9 TaskWizard (org.eclipse.wst.server.ui.internal.wizard.TaskWizard)9 LicenseWizardFragment (org.eclipse.wst.server.ui.internal.wizard.fragment.LicenseWizardFragment)7 DownloadableAdapterLicenseWizardFragment (org.eclipse.wst.server.ui.internal.wizard.fragment.DownloadableAdapterLicenseWizardFragment)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 List (java.util.List)5 CoreException (org.eclipse.core.runtime.CoreException)5 ArrayList (java.util.ArrayList)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)3 TaskModel (org.eclipse.wst.server.core.TaskModel)3 Job (org.eclipse.core.runtime.jobs.Job)2 File (java.io.File)1 IOException (java.io.IOException)1 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)1 IPath (org.eclipse.core.runtime.IPath)1 IStatus (org.eclipse.core.runtime.IStatus)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1