+ * + * TODO: Implement me. Please. + */ +public class NewLTTngProjectMainWizardPage extends WizardNewProjectCreationPage { + + /** + * @param pageName + */ + public NewLTTngProjectMainWizardPage(String pageName) { + super(pageName); + } + +} diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/NewLTTngProjectWizard.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/NewLTTngProjectWizard.java new file mode 100644 index 0000000000..b7113bc1b0 --- /dev/null +++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/NewLTTngProjectWizard.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * Copyright (c) 2009, 2011 Ericsson, MontaVista Software + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Francois Chouinard - Initial API and implementation + * Yufen Kuo (ykuo@mvista.com) - add support to allow user specify trace library path + * Francois Chouinard - Rebase on TMF NewProjectWizard + *******************************************************************************/ + +package org.eclipse.linuxtools.lttng.ui.views.project.dialogs; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.linuxtools.lttng.LTTngProjectNature; +import org.eclipse.linuxtools.lttng.TraceHelper; +import org.eclipse.linuxtools.tmf.TmfProjectNature; +import org.eclipse.linuxtools.tmf.ui.project.wizards.NewTmfProjectWizard; + +/** + * NewLTTngProjectWizard + *
+ */ +public class NewLTTngProjectWizard extends NewTmfProjectWizard { + + // ------------------------------------------------------------------------ + // Constants + // ------------------------------------------------------------------------ + + private static final String TRACE_LIBRARY_PATH = "traceLibraryPath"; //$NON-NLS-1$ + + // ------------------------------------------------------------------------ + // Variables + // ------------------------------------------------------------------------ + + private TraceLibraryPathWizardPage traceLibraryPathPage; + + // ------------------------------------------------------------------------ + // Construction + // ------------------------------------------------------------------------ + + public NewLTTngProjectWizard() { + this(Messages.NewProjectWizard_Title, Messages.NewProjectWizard_Description); + } + + public NewLTTngProjectWizard(String title, String desc) { + super(title, desc); + } + + // ------------------------------------------------------------------------ + // NewProjectWizard + // ------------------------------------------------------------------------ + + @Override + public void addPages() { + super.addPages(); + traceLibraryPathPage = new TraceLibraryPathWizardPage(Messages.NewProjectWizard_Title); + traceLibraryPathPage.setTitle(Messages.TraceLibraryPathWizardPage_Title); + traceLibraryPathPage.setDescription(Messages.TraceLibraryPathWizardPage_Description); + addPage(traceLibraryPathPage); + } + + @Override + public boolean performFinish() { + // Create the tracing project + super.performFinish(); + + // Add the LTTng nature + try { + IProjectDescription description = fProject.getDescription(); + description.setNatureIds(new String[] { TmfProjectNature.ID, LTTngProjectNature.ID }); + fProject.setDescription(description, null); + } catch (CoreException e) { + } + + // Set the library path + String traceLibraryPath = traceLibraryPathPage.getPath(); + if (traceLibraryPath != null) { + return TraceHelper.setProjectPreference(fProject, TRACE_LIBRARY_PATH, traceLibraryPath); + } + + return true; + } + + // ------------------------------------------------------------------------ + // Operations + // ------------------------------------------------------------------------ + + public IProject getProject() { + return fProject; + } + +} \ No newline at end of file diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/NewProjectMainWizardPage.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/NewProjectMainWizardPage.java deleted file mode 100644 index 48da18ecb4..0000000000 --- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/NewProjectMainWizardPage.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Francois Chouinard - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.lttng.ui.views.project.dialogs; - -import org.eclipse.ui.dialogs.WizardNewProjectCreationPage; - -/** - * NewProjectMainWizardPage - *
- * - * TODO: Implement me. Please. - */ -public class NewProjectMainWizardPage extends WizardNewProjectCreationPage { - - /** - * @param pageName - */ - public NewProjectMainWizardPage(String pageName) { - super(pageName); - } - -} diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/NewProjectWizard.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/NewProjectWizard.java deleted file mode 100644 index 7f0ce58e33..0000000000 --- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/dialogs/NewProjectWizard.java +++ /dev/null @@ -1,159 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2011 Ericsson, MontaVista Software - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Francois Chouinard - Initial API and implementation - * Yufen Kuo (ykuo@mvista.com) - add support to allow user specify trace library path - *******************************************************************************/ - -package org.eclipse.linuxtools.lttng.ui.views.project.dialogs; - -import java.net.URI; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.linuxtools.lttng.LTTngProjectNature; -import org.eclipse.linuxtools.lttng.TraceHelper; -import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin; -import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectNode; -import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard; - -/** - * NewProjectWizard - *
- * TODO: Implement me. Please.
- */
-public class NewProjectWizard extends BasicNewResourceWizard {
-
- private String fTtitle;
- private String fDescription;
-
- protected NewProjectMainWizardPage fMainPage;
- protected String fProjectName;
- protected URI fProjectLocation;
- protected IConfigurationElement fConfigElement;
-
- protected IProject fProject;
- private TraceLibraryPathWizardPage traceLibraryPathPage;
-
- /**
- *
- */
- public NewProjectWizard() {
- this(Messages.NewProjectWizard_Title, Messages.NewProjectWizard_Description);
- }
-
- /**
- * @param title
- * @param desc
- */
- public NewProjectWizard(String title, String desc) {
- super();
- setDialogSettings(LTTngUiPlugin.getDefault().getDialogSettings());
- setNeedsProgressMonitor(true);
- setForcePreviousAndNextButtons(true);
- setWindowTitle(title);
- fTtitle = title;
- fDescription = desc;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.Wizard#addPages()
- */
- @Override
- public void addPages() {
- fMainPage= new NewProjectMainWizardPage(Messages.NewProjectWizard_Title);
- fMainPage.setTitle(fTtitle);
- fMainPage.setDescription(fDescription);
- addPage(fMainPage);
- traceLibraryPathPage = new TraceLibraryPathWizardPage(Messages.NewProjectWizard_Title);
- traceLibraryPathPage.setTitle(Messages.TraceLibraryPathWizardPage_Title);
- traceLibraryPathPage.setDescription(Messages.TraceLibraryPathWizardPage_Description);
- addPage(traceLibraryPathPage);
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.Wizard#performCancel()
- */
- @Override
- public boolean performCancel() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.Wizard#performFinish()
- */
- @Override
- public boolean performFinish() {
- fProjectName = fMainPage.getProjectName();
- fProjectLocation = fMainPage.useDefaults() ? null : fMainPage.getLocationURI();
- fProject = createProject(fProjectName, fProjectLocation, new NullProgressMonitor());
- String traceLibraryPath = traceLibraryPathPage.getPath();
- if (traceLibraryPath != null){
- return TraceHelper.setProjectPreference(fProject, "traceLibraryPath", traceLibraryPath);
- }
- return true;
- }
-
- public IProject getProject() {
- return fProject;
- }
-
- /**
- * @param projectName
- * @param projectLocation
- * @param monitor
- * @return
- */
- private IProject createProject(String projectName, URI projectLocation, IProgressMonitor monitor) {
-
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IWorkspaceRoot root = workspace.getRoot();
- IProject project = root.getProject(projectName);
-
- try {
- if (!project.exists()) {
- IProjectDescription description = workspace.newProjectDescription(project.getName());
- if (projectLocation != null)
- description.setLocationURI(projectLocation);
- project.create(description, monitor);
- }
-
- if (!project.isOpen())
- project.open(monitor);
-
- IProjectDescription description = project.getDescription();
- description.setNatureIds(new String[] { LTTngProjectNature.ID } );
- project.setDescription(description, null);
-
- IFolder folder = project.getFolder(LTTngProjectNode.TRACE_FOLDER_NAME);
- if (!folder.exists())
- folder.create(true, true, null);
-
- folder = project.getFolder(LTTngProjectNode.EXPER_FOLDER_NAME);
- if (!folder.exists())
- folder.create(true, true, null);
-
- return project;
- }
- catch (CoreException e) {
- e.printStackTrace();
- }
- return null;
- }
-
-}
\ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/handlers/NewProjectHandler.java b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/handlers/NewProjectHandler.java
index ac001a7370..85ce652cfe 100644
--- a/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/handlers/NewProjectHandler.java
+++ b/lttng/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/handlers/NewProjectHandler.java
@@ -20,7 +20,7 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.linuxtools.lttng.ui.views.project.ProjectView;
-import org.eclipse.linuxtools.lttng.ui.views.project.dialogs.NewProjectWizard;
+import org.eclipse.linuxtools.lttng.ui.views.project.dialogs.NewLTTngProjectWizard;
import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectRoot;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPart;
@@ -73,7 +73,7 @@ public class NewProjectHandler implements IHandler {
// Fire the New Project Wizard
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- NewProjectWizard wizard = new NewProjectWizard();
+ NewLTTngProjectWizard wizard = new NewLTTngProjectWizard();
WizardDialog dialog = new WizardDialog(shell, wizard);
dialog.open();
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF b/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF
index 0acbe2ceed..8023ba7b30 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF
@@ -20,6 +20,7 @@ Export-Package: org.eclipse.linuxtools.tmf.ui,
org.eclipse.linuxtools.tmf.ui.editors,
org.eclipse.linuxtools.tmf.ui.parsers,
org.eclipse.linuxtools.tmf.ui.project.model,
+ org.eclipse.linuxtools.tmf.ui.project.wizards,
org.eclipse.linuxtools.tmf.ui.signal,
org.eclipse.linuxtools.tmf.ui.viewers,
org.eclipse.linuxtools.tmf.ui.viewers.events,
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/plugin.xml b/lttng/org.eclipse.linuxtools.tmf.ui/plugin.xml
index 167e6ac04f..ecaca74882 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/plugin.xml
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/plugin.xml
@@ -93,7 +93,7 @@
- *
- * TODO: Implement me. Please.
- */
-public class NewProjectMainWizardPage extends WizardNewProjectCreationPage {
-
- /**
- * @param pageName
- */
- public NewProjectMainWizardPage(String pageName) {
- super(pageName);
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewProjectWizard.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewProjectWizard.java
deleted file mode 100644
index a4e626e183..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewProjectWizard.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.ui.project.wizards;
-
-import java.net.URI;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExecutableExtension;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.linuxtools.tmf.TmfProjectNature;
-import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin;
-import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder;
-import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder;
-import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
-import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
-
-/**
- * NewProjectWizard
- *
- */
-public class NewProjectWizard extends BasicNewResourceWizard implements IExecutableExtension {
-
- private final String fTtitle;
- private final String fDescription;
-
- protected NewProjectMainWizardPage fMainPage;
- protected String fProjectName;
- protected URI fProjectLocation;
- protected IConfigurationElement fConfigElement;
-
- protected IProject fProject;
-
- /**
- *
- */
- public NewProjectWizard() {
- this(Messages.NewProjectWizard_DialogHeader, Messages.NewProjectWizard_DialogMessage);
- }
-
- /**
- * @param title
- * @param desc
- */
- public NewProjectWizard(String title, String desc) {
- super();
- setDialogSettings(TmfUiPlugin.getDefault().getDialogSettings());
- setNeedsProgressMonitor(true);
- setForcePreviousAndNextButtons(true);
- setWindowTitle(title);
- fTtitle = title;
- fDescription = desc;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.wizard.Wizard#addPages()
- */
- @Override
- public void addPages() {
- fMainPage = new NewProjectMainWizardPage(Messages.NewProjectWizard_DialogHeader);
- fMainPage.setTitle(fTtitle);
- fMainPage.setDescription(fDescription);
- addPage(fMainPage);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.wizard.Wizard#performCancel()
- */
- @Override
- public boolean performCancel() {
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.wizard.Wizard#performFinish()
- */
- @Override
- public boolean performFinish() {
- fProjectName = fMainPage.getProjectName();
- fProjectLocation = fMainPage.useDefaults() ? null : fMainPage.getLocationURI();
- fProject = createProject(fProjectName, fProjectLocation, new NullProgressMonitor());
- BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
- return true;
- }
-
- /**
- * @param projectName
- * @param projectLocation
- * @param monitor
- * @return
- */
- private IProject createProject(String projectName, URI projectLocation, IProgressMonitor monitor) {
-
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IWorkspaceRoot root = workspace.getRoot();
- IProject project = root.getProject(projectName);
-
- try {
- if (!project.exists()) {
- IProjectDescription description = workspace.newProjectDescription(project.getName());
- if (projectLocation != null)
- description.setLocationURI(projectLocation);
- project.create(description, monitor);
- }
-
- if (!project.isOpen())
- project.open(monitor);
-
- IProjectDescription description = project.getDescription();
- description.setNatureIds(new String[] { TmfProjectNature.ID });
- project.setDescription(description, null);
-
- IFolder folder = project.getFolder(TmfTraceFolder.TRACE_FOLDER_NAME);
- if (!folder.exists())
- folder.create(true, true, null);
-
- folder = project.getFolder(TmfExperimentFolder.EXPER_FOLDER_NAME);
- if (!folder.exists())
- folder.create(true, true, null);
-
- return project;
- } catch (CoreException e) {
- e.printStackTrace();
- }
- return null;
- }
-
- // ------------------------------------------------------------------------
- // IExecutableExtension
- // ------------------------------------------------------------------------
-
- @Override
- public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
- fConfigElement = config;
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewTmfProjectMainWizardPage.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewTmfProjectMainWizardPage.java
new file mode 100644
index 0000000000..6e71cf8db1
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewTmfProjectMainWizardPage.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.project.wizards;
+
+import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
+
+/**
+ * NewProjectMainWizardPage
+ *
+ *
+ * TODO: Implement me. Please.
+ */
+public class NewTmfProjectMainWizardPage extends WizardNewProjectCreationPage {
+
+ /**
+ * @param pageName
+ */
+ public NewTmfProjectMainWizardPage(String pageName) {
+ super(pageName);
+ }
+
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewTmfProjectWizard.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewTmfProjectWizard.java
new file mode 100644
index 0000000000..092ea3bf24
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/NewTmfProjectWizard.java
@@ -0,0 +1,160 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2011 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.project.wizards;
+
+import java.net.URI;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.linuxtools.tmf.TmfProjectNature;
+import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder;
+import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
+import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
+
+/**
+ * NewTmfProjectWizard
+ *
+ */
+public class NewTmfProjectWizard extends BasicNewResourceWizard implements IExecutableExtension {
+
+ private final String fTtitle;
+ private final String fDescription;
+
+ protected NewTmfProjectMainWizardPage fMainPage;
+ protected String fProjectName;
+ protected URI fProjectLocation;
+ protected IConfigurationElement fConfigElement;
+
+ protected IProject fProject;
+
+ /**
+ *
+ */
+ public NewTmfProjectWizard() {
+ this(Messages.NewProjectWizard_DialogHeader, Messages.NewProjectWizard_DialogMessage);
+ }
+
+ /**
+ * @param title
+ * @param desc
+ */
+ public NewTmfProjectWizard(String title, String desc) {
+ super();
+ setDialogSettings(TmfUiPlugin.getDefault().getDialogSettings());
+ setNeedsProgressMonitor(true);
+ setForcePreviousAndNextButtons(true);
+ setWindowTitle(title);
+ fTtitle = title;
+ fDescription = desc;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
+ */
+ @Override
+ public void addPages() {
+ fMainPage = new NewTmfProjectMainWizardPage(Messages.NewProjectWizard_DialogHeader);
+ fMainPage.setTitle(fTtitle);
+ fMainPage.setDescription(fDescription);
+ addPage(fMainPage);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#performCancel()
+ */
+ @Override
+ public boolean performCancel() {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+ fProjectName = fMainPage.getProjectName();
+ fProjectLocation = fMainPage.useDefaults() ? null : fMainPage.getLocationURI();
+ fProject = createProject(fProjectName, fProjectLocation, new NullProgressMonitor());
+ BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
+ return true;
+ }
+
+ /**
+ * @param projectName
+ * @param projectLocation
+ * @param monitor
+ * @return
+ */
+ private IProject createProject(String projectName, URI projectLocation, IProgressMonitor monitor) {
+
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot root = workspace.getRoot();
+ IProject project = root.getProject(projectName);
+
+ try {
+ if (!project.exists()) {
+ IProjectDescription description = workspace.newProjectDescription(project.getName());
+ if (projectLocation != null)
+ description.setLocationURI(projectLocation);
+ project.create(description, monitor);
+ }
+
+ if (!project.isOpen())
+ project.open(monitor);
+
+ IProjectDescription description = project.getDescription();
+ description.setNatureIds(new String[] { TmfProjectNature.ID });
+ project.setDescription(description, null);
+
+ IFolder folder = project.getFolder(TmfTraceFolder.TRACE_FOLDER_NAME);
+ if (!folder.exists())
+ folder.create(true, true, null);
+
+ folder = project.getFolder(TmfExperimentFolder.EXPER_FOLDER_NAME);
+ if (!folder.exists())
+ folder.create(true, true, null);
+
+ return project;
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ // ------------------------------------------------------------------------
+ // IExecutableExtension
+ // ------------------------------------------------------------------------
+
+ @Override
+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
+ fConfigElement = config;
+ }
+
+}
--
cgit v1.2.3