1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package pl.edu.agh.cast.data.ui.importer.action;
19
20 import org.eclipse.core.resources.IProject;
21 import org.eclipse.core.runtime.CoreException;
22 import org.eclipse.jface.action.IAction;
23 import org.eclipse.jface.wizard.WizardDialog;
24 import org.eclipse.osgi.util.NLS;
25 import org.eclipse.ui.PlatformUI;
26
27 import pl.edu.agh.cast.CastApplication;
28 import pl.edu.agh.cast.data.ui.importer.wizard.ImportWizard;
29 import pl.edu.agh.cast.data.util.Messages;
30 import pl.edu.agh.cast.navigator.ui.action.CreateProjectAction;
31 import pl.edu.agh.cast.ui.util.MsgBoxHelper;
32
33
34
35
36
37
38 public class ImportWizardAction {
39
40 private IProject project = null;
41
42
43
44
45
46
47 public void run(IAction action) {
48 if (project == null) {
49 project = CastApplication.getActiveProject();
50 }
51
52 if (project == null) {
53 new CreateProjectAction().run(null);
54 IProject proj = CastApplication.getActiveProject();
55 if (proj == null) {
56 return;
57 }
58 setProject(proj);
59 }
60
61 ImportWizard wizard = null;
62 try {
63
64 wizard = new ImportWizard(project);
65 } catch (CoreException e) {
66 MsgBoxHelper.showErrorBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
67 Messages.ImportWizardAction_2, NLS.bind(Messages.ImportWizardAction_3, e.getMessage()));
68 return;
69 }
70
71 WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard);
72
73
74 dialog.setTitle(Messages.ImportBillingAction_0);
75 dialog.open();
76 }
77
78
79
80
81 protected IProject getProject() {
82 return project;
83 }
84
85
86
87
88
89 protected void setProject(IProject project) {
90 this.project = project;
91 }
92 }