]>
Commit | Line | Data |
---|---|---|
1 | /******************************************************************************* | |
2 | * Copyright (c) 2009, 2014 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Francois Chouinard - Initial API and implementation | |
11 | * Bernd Hufmann - Moved project creation utility method to TmfProjectRegistry | |
12 | *******************************************************************************/ | |
13 | ||
14 | package org.eclipse.tracecompass.tmf.ui.project.wizards; | |
15 | ||
16 | import java.net.URI; | |
17 | ||
18 | import org.eclipse.core.resources.IProject; | |
19 | import org.eclipse.core.runtime.CoreException; | |
20 | import org.eclipse.core.runtime.IConfigurationElement; | |
21 | import org.eclipse.core.runtime.IExecutableExtension; | |
22 | import org.eclipse.core.runtime.NullProgressMonitor; | |
23 | import org.eclipse.jface.viewers.IStructuredSelection; | |
24 | import org.eclipse.jface.wizard.Wizard; | |
25 | import org.eclipse.tracecompass.internal.tmf.ui.Activator; | |
26 | import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectRegistry; | |
27 | import org.eclipse.ui.INewWizard; | |
28 | import org.eclipse.ui.IWorkbench; | |
29 | import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard; | |
30 | ||
31 | /** | |
32 | * Wizard implementation for creating a TMF tracing project. | |
33 | * | |
34 | * @author Francois Chouinard | |
35 | */ | |
36 | public class NewTmfProjectWizard extends Wizard implements INewWizard, IExecutableExtension { | |
37 | ||
38 | // ------------------------------------------------------------------------ | |
39 | // Constants | |
40 | // ------------------------------------------------------------------------ | |
41 | ||
42 | /** | |
43 | * The wizard id | |
44 | */ | |
45 | public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.ui.wizards.newProject"; //$NON-NLS-1$ | |
46 | ||
47 | // ------------------------------------------------------------------------ | |
48 | // Attributes | |
49 | // ------------------------------------------------------------------------ | |
50 | ||
51 | private final String fTtitle; | |
52 | private final String fDescription; | |
53 | ||
54 | /** | |
55 | * Wizard main page | |
56 | */ | |
57 | protected NewTmfProjectMainWizardPage fMainPage; | |
58 | ||
59 | /** | |
60 | * The Project name | |
61 | */ | |
62 | protected String fProjectName; | |
63 | ||
64 | /** | |
65 | * The project location | |
66 | */ | |
67 | ||
68 | protected URI fProjectLocation; | |
69 | ||
70 | /** | |
71 | * The configuration element. | |
72 | */ | |
73 | protected IConfigurationElement fConfigElement; | |
74 | ||
75 | /** | |
76 | * The project reference | |
77 | */ | |
78 | protected IProject fProject; | |
79 | ||
80 | // ------------------------------------------------------------------------ | |
81 | // Constructors | |
82 | // ------------------------------------------------------------------------ | |
83 | ||
84 | /** | |
85 | * Default constructor | |
86 | */ | |
87 | public NewTmfProjectWizard() { | |
88 | this(Messages.NewProjectWizard_DialogHeader, Messages.NewProjectWizard_DialogMessage); | |
89 | } | |
90 | ||
91 | /** | |
92 | * Constructor | |
93 | * @param title The tile string | |
94 | * @param desc The description string | |
95 | */ | |
96 | public NewTmfProjectWizard(String title, String desc) { | |
97 | super(); | |
98 | setDialogSettings(Activator.getDefault().getDialogSettings()); | |
99 | setNeedsProgressMonitor(true); | |
100 | setForcePreviousAndNextButtons(true); | |
101 | setWindowTitle(title); | |
102 | fTtitle = title; | |
103 | fDescription = desc; | |
104 | } | |
105 | ||
106 | // ------------------------------------------------------------------------ | |
107 | // Wizard | |
108 | // ------------------------------------------------------------------------ | |
109 | ||
110 | @Override | |
111 | public void addPages() { | |
112 | fMainPage = new NewTmfProjectMainWizardPage(Messages.NewProjectWizard_DialogHeader); | |
113 | fMainPage.setTitle(fTtitle); | |
114 | fMainPage.setDescription(fDescription); | |
115 | addPage(fMainPage); | |
116 | } | |
117 | ||
118 | @Override | |
119 | public boolean performCancel() { | |
120 | return true; | |
121 | } | |
122 | ||
123 | @Override | |
124 | public boolean performFinish() { | |
125 | fProjectName = fMainPage.getProjectName(); | |
126 | fProjectLocation = fMainPage.useDefaults() ? null : fMainPage.getLocationURI(); | |
127 | fProject = TmfProjectRegistry.createProject(fProjectName, fProjectLocation, new NullProgressMonitor()); | |
128 | BasicNewProjectResourceWizard.updatePerspective(fConfigElement); | |
129 | return true; | |
130 | } | |
131 | ||
132 | // ------------------------------------------------------------------------ | |
133 | // INewWizard | |
134 | // ------------------------------------------------------------------------ | |
135 | ||
136 | @Override | |
137 | public void init(IWorkbench iworkbench, IStructuredSelection istructuredselection) { | |
138 | } | |
139 | ||
140 | // ------------------------------------------------------------------------ | |
141 | // IExecutableExtension | |
142 | // ------------------------------------------------------------------------ | |
143 | ||
144 | @Override | |
145 | public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException { | |
146 | fConfigElement = config; | |
147 | } | |
148 | ||
149 | } |