1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/*******************************************************************************
* Copyright (c) 2004, 2007 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.framework.ui.plugin.util;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWizard;
/**
* @author Robert A. Fisher
*/
public final class Wizards {
public static final void initAndOpen(IWorkbenchWizard wizard, IViewPart viewPart) {
initAndOpen(wizard, viewPart, viewPart.getViewSite().getWorkbenchWindow());
}
public static final void initAndOpen(IWorkbenchWizard wizard, IViewPart viewPart, IStructuredSelection selection) {
initAndOpen(wizard, viewPart.getViewSite().getWorkbenchWindow(), selection);
}
public static final void initAndOpen(IWorkbenchWizard wizard, IViewPart viewPart, IWorkbenchWindow workbenchWindow) {
IStructuredSelection selectionToPass;
// get the current workbench selection
ISelection workbenchSelection = workbenchWindow.getSelectionService().getSelection();
if (workbenchSelection instanceof IStructuredSelection) {
selectionToPass = (IStructuredSelection) workbenchSelection;
} else {
selectionToPass = StructuredSelection.EMPTY;
}
initAndOpen(wizard, viewPart.getViewSite().getWorkbenchWindow(), selectionToPass);
}
public static final void initAndOpen(IWorkbenchWizard wizard, IWorkbenchWindow workbenchWindow, IStructuredSelection selection) {
wizard.init(workbenchWindow.getWorkbench(), selection);
Shell parent = workbenchWindow.getShell();
WizardDialog dialog = new WizardDialog(parent, wizard);
dialog.create();
dialog.open();
}
}
|