Commit | Line | Data |
---|---|---|
9501fb58 FC |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009, 2011 Ericsson, MontaVista Software | |
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 | * Yufen Kuo (ykuo@mvista.com) - add support to allow user specify trace library path | |
12 | * Francois Chouinard - Rebase on TMF NewProjectWizard | |
13 | *******************************************************************************/ | |
14 | ||
15 | package org.eclipse.linuxtools.lttng.ui.views.project.dialogs; | |
16 | ||
17 | import org.eclipse.core.resources.IProject; | |
18 | import org.eclipse.core.resources.IProjectDescription; | |
19 | import org.eclipse.core.runtime.CoreException; | |
6c13869b FC |
20 | import org.eclipse.linuxtools.lttng.core.LTTngProjectNature; |
21 | import org.eclipse.linuxtools.lttng.core.TraceHelper; | |
22 | import org.eclipse.linuxtools.tmf.core.TmfProjectNature; | |
9501fb58 FC |
23 | import org.eclipse.linuxtools.tmf.ui.project.wizards.NewTmfProjectWizard; |
24 | ||
25 | /** | |
26 | * <b><u>NewLTTngProjectWizard</u></b> | |
27 | * <p> | |
28 | */ | |
29 | public class NewLTTngProjectWizard extends NewTmfProjectWizard { | |
30 | ||
31 | // ------------------------------------------------------------------------ | |
32 | // Constants | |
33 | // ------------------------------------------------------------------------ | |
34 | ||
35 | private static final String TRACE_LIBRARY_PATH = "traceLibraryPath"; //$NON-NLS-1$ | |
36 | ||
37 | // ------------------------------------------------------------------------ | |
38 | // Variables | |
39 | // ------------------------------------------------------------------------ | |
40 | ||
41 | private TraceLibraryPathWizardPage traceLibraryPathPage; | |
42 | ||
43 | // ------------------------------------------------------------------------ | |
44 | // Construction | |
45 | // ------------------------------------------------------------------------ | |
46 | ||
47 | public NewLTTngProjectWizard() { | |
48 | this(Messages.NewProjectWizard_Title, Messages.NewProjectWizard_Description); | |
49 | } | |
50 | ||
51 | public NewLTTngProjectWizard(String title, String desc) { | |
52 | super(title, desc); | |
53 | } | |
54 | ||
55 | // ------------------------------------------------------------------------ | |
56 | // NewProjectWizard | |
57 | // ------------------------------------------------------------------------ | |
58 | ||
59 | @Override | |
60 | public void addPages() { | |
61 | super.addPages(); | |
62 | traceLibraryPathPage = new TraceLibraryPathWizardPage(Messages.NewProjectWizard_Title); | |
63 | traceLibraryPathPage.setTitle(Messages.TraceLibraryPathWizardPage_Title); | |
64 | traceLibraryPathPage.setDescription(Messages.TraceLibraryPathWizardPage_Description); | |
65 | addPage(traceLibraryPathPage); | |
66 | } | |
67 | ||
68 | @Override | |
69 | public boolean performFinish() { | |
70 | // Create the tracing project | |
71 | super.performFinish(); | |
72 | ||
73 | // Add the LTTng nature | |
74 | try { | |
75 | IProjectDescription description = fProject.getDescription(); | |
76 | description.setNatureIds(new String[] { TmfProjectNature.ID, LTTngProjectNature.ID }); | |
77 | fProject.setDescription(description, null); | |
78 | } catch (CoreException e) { | |
79 | } | |
80 | ||
81 | // Set the library path | |
82 | String traceLibraryPath = traceLibraryPathPage.getPath(); | |
83 | if (traceLibraryPath != null) { | |
84 | return TraceHelper.setProjectPreference(fProject, TRACE_LIBRARY_PATH, traceLibraryPath); | |
85 | } | |
86 | ||
87 | return true; | |
88 | } | |
89 | ||
90 | // ------------------------------------------------------------------------ | |
91 | // Operations | |
92 | // ------------------------------------------------------------------------ | |
93 | ||
94 | public IProject getProject() { | |
95 | return fProject; | |
96 | } | |
97 | ||
98 | } |