Fix some null warnings
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / project / wizards / NewTmfProjectWizard.java
CommitLineData
abfad0aa 1/*******************************************************************************
ed902a2b 2 * Copyright (c) 2009, 2014 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
2bdf0193 14package org.eclipse.tracecompass.tmf.ui.project.wizards;
abfad0aa
FC
15
16import java.net.URI;
17
abfad0aa 18import org.eclipse.core.resources.IProject;
abfad0aa
FC
19import org.eclipse.core.runtime.CoreException;
20import org.eclipse.core.runtime.IConfigurationElement;
12c155f5 21import org.eclipse.core.runtime.IExecutableExtension;
abfad0aa 22import org.eclipse.core.runtime.NullProgressMonitor;
8f5c078d
FC
23import org.eclipse.jface.viewers.IStructuredSelection;
24import org.eclipse.jface.wizard.Wizard;
2bdf0193
AM
25import org.eclipse.tracecompass.internal.tmf.ui.Activator;
26import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectRegistry;
8f5c078d
FC
27import org.eclipse.ui.INewWizard;
28import org.eclipse.ui.IWorkbench;
12c155f5 29import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
abfad0aa
FC
30
31/**
b544077e 32 * Wizard implementation for creating a TMF tracing project.
ea279a69 33 *
b544077e 34 * @author Francois Chouinard
abfad0aa 35 */
8f5c078d 36public class NewTmfProjectWizard extends Wizard implements INewWizard, IExecutableExtension {
abfad0aa 37
ea279a69
FC
38 // ------------------------------------------------------------------------
39 // Constants
40 // ------------------------------------------------------------------------
41
42 /**
43 * The wizard id
ea279a69
FC
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
12c155f5
FC
51 private final String fTtitle;
52 private final String fDescription;
abfad0aa 53
b544077e
BH
54 /**
55 * Wizard main page
56 */
9501fb58 57 protected NewTmfProjectMainWizardPage fMainPage;
ea279a69 58
b544077e
BH
59 /**
60 * The Project name
61 */
abfad0aa 62 protected String fProjectName;
ea279a69 63
b544077e
BH
64 /**
65 * The project location
66 */
ea279a69 67
abfad0aa 68 protected URI fProjectLocation;
ea279a69 69
b544077e
BH
70 /**
71 * The configuration element.
72 */
abfad0aa
FC
73 protected IConfigurationElement fConfigElement;
74
b544077e
BH
75 /**
76 * The project reference
77 */
abfad0aa
FC
78 protected IProject fProject;
79
ea279a69
FC
80 // ------------------------------------------------------------------------
81 // Constructors
82 // ------------------------------------------------------------------------
83
abfad0aa 84 /**
b544077e 85 * Default constructor
abfad0aa 86 */
9501fb58 87 public NewTmfProjectWizard() {
b9763f53 88 this(Messages.NewProjectWizard_DialogHeader, Messages.NewProjectWizard_DialogMessage);
abfad0aa
FC
89 }
90
91 /**
b544077e
BH
92 * Constructor
93 * @param title The tile string
94 * @param desc The description string
abfad0aa 95 */
9501fb58 96 public NewTmfProjectWizard(String title, String desc) {
abfad0aa 97 super();
8fd82db5 98 setDialogSettings(Activator.getDefault().getDialogSettings());
abfad0aa
FC
99 setNeedsProgressMonitor(true);
100 setForcePreviousAndNextButtons(true);
101 setWindowTitle(title);
102 fTtitle = title;
103 fDescription = desc;
104 }
105
ea279a69
FC
106 // ------------------------------------------------------------------------
107 // Wizard
108 // ------------------------------------------------------------------------
109
abfad0aa
FC
110 @Override
111 public void addPages() {
9501fb58 112 fMainPage = new NewTmfProjectMainWizardPage(Messages.NewProjectWizard_DialogHeader);
abfad0aa
FC
113 fMainPage.setTitle(fTtitle);
114 fMainPage.setDescription(fDescription);
115 addPage(fMainPage);
116 }
117
abfad0aa
FC
118 @Override
119 public boolean performCancel() {
120 return true;
121 }
122
abfad0aa
FC
123 @Override
124 public boolean performFinish() {
125 fProjectName = fMainPage.getProjectName();
126 fProjectLocation = fMainPage.useDefaults() ? null : fMainPage.getLocationURI();
889da47d 127 fProject = TmfProjectRegistry.createProject(fProjectName, fProjectLocation, new NullProgressMonitor());
12c155f5 128 BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
abfad0aa
FC
129 return true;
130 }
131
8f5c078d
FC
132 // ------------------------------------------------------------------------
133 // INewWizard
134 // ------------------------------------------------------------------------
135
8f5c078d
FC
136 @Override
137 public void init(IWorkbench iworkbench, IStructuredSelection istructuredselection) {
138 }
139
12c155f5
FC
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}
This page took 0.104533 seconds and 5 git commands to generate.