ss: Move plugins to Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / project / wizards / NewTmfProjectWizard.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2013 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.linuxtools.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.linuxtools.internal.tmf.ui.Activator;
26 import org.eclipse.linuxtools.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 * @version 1.0
35 * @author Francois Chouinard
36 */
37 public class NewTmfProjectWizard extends Wizard implements INewWizard, IExecutableExtension {
38
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
54 private final String fTtitle;
55 private final String fDescription;
56
57 /**
58 * Wizard main page
59 */
60 protected NewTmfProjectMainWizardPage fMainPage;
61
62 /**
63 * The Project name
64 */
65 protected String fProjectName;
66
67 /**
68 * The project location
69 */
70
71 protected URI fProjectLocation;
72
73 /**
74 * The configuration element.
75 */
76 protected IConfigurationElement fConfigElement;
77
78 /**
79 * The project reference
80 */
81 protected IProject fProject;
82
83 // ------------------------------------------------------------------------
84 // Constructors
85 // ------------------------------------------------------------------------
86
87 /**
88 * Default constructor
89 */
90 public NewTmfProjectWizard() {
91 this(Messages.NewProjectWizard_DialogHeader, Messages.NewProjectWizard_DialogMessage);
92 }
93
94 /**
95 * Constructor
96 * @param title The tile string
97 * @param desc The description string
98 */
99 public NewTmfProjectWizard(String title, String desc) {
100 super();
101 setDialogSettings(Activator.getDefault().getDialogSettings());
102 setNeedsProgressMonitor(true);
103 setForcePreviousAndNextButtons(true);
104 setWindowTitle(title);
105 fTtitle = title;
106 fDescription = desc;
107 }
108
109 // ------------------------------------------------------------------------
110 // Wizard
111 // ------------------------------------------------------------------------
112
113 @Override
114 public void addPages() {
115 fMainPage = new NewTmfProjectMainWizardPage(Messages.NewProjectWizard_DialogHeader);
116 fMainPage.setTitle(fTtitle);
117 fMainPage.setDescription(fDescription);
118 addPage(fMainPage);
119 }
120
121 @Override
122 public boolean performCancel() {
123 return true;
124 }
125
126 @Override
127 public boolean performFinish() {
128 fProjectName = fMainPage.getProjectName();
129 fProjectLocation = fMainPage.useDefaults() ? null : fMainPage.getLocationURI();
130 fProject = TmfProjectRegistry.createProject(fProjectName, fProjectLocation, new NullProgressMonitor());
131 BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
132 return true;
133 }
134
135 // ------------------------------------------------------------------------
136 // INewWizard
137 // ------------------------------------------------------------------------
138
139 @Override
140 public void init(IWorkbench iworkbench, IStructuredSelection istructuredselection) {
141 }
142
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 }
This page took 0.034521 seconds and 5 git commands to generate.