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