Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2016-10-19 14:43:55 +0000
committerGerrit Code Review @ Eclipse.org2016-10-19 22:32:48 +0000
commit78ba80e1d50333b8021c01afa7edbd9815612ad8 (patch)
treea2db6229a7fdc5c4b0d1986e44921348693046e2
parentfbccef3ff12c3d394e30a8bd1f1198512cff3161 (diff)
downloadorg.eclipse.cdt-78ba80e1d50333b8021c01afa7edbd9815612ad8.tar.gz
org.eclipse.cdt-78ba80e1d50333b8021c01afa7edbd9815612ad8.tar.xz
org.eclipse.cdt-78ba80e1d50333b8021c01afa7edbd9815612ad8.zip
Add New Empty CMake project wizard.
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeProjectGenerator.java33
-rw-r--r--build/org.eclipse.cdt.cmake.ui/plugin.xml17
-rw-r--r--build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/EmptyCMakeProjectWizard.java47
3 files changed, 82 insertions, 15 deletions
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeProjectGenerator.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeProjectGenerator.java
index 82cc0aea8d..de95869895 100644
--- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeProjectGenerator.java
+++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeProjectGenerator.java
@@ -27,6 +27,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.tools.templates.freemarker.FMProjectGenerator;
import org.eclipse.tools.templates.freemarker.SourceRoot;
+import org.eclipse.tools.templates.freemarker.TemplateManifest;
import org.osgi.framework.Bundle;
public class CMakeProjectGenerator extends FMProjectGenerator {
@@ -54,25 +55,29 @@ public class CMakeProjectGenerator extends FMProjectGenerator {
public void generate(Map<String, Object> model, IProgressMonitor monitor) throws CoreException {
super.generate(model, monitor);
- // Create the source folders
- IProject project = getProject();
List<IPathEntry> entries = new ArrayList<>();
- List<SourceRoot> srcRoots = getManifest().getSrcRoots();
- if (srcRoots != null && !srcRoots.isEmpty()) {
- for (SourceRoot srcRoot : srcRoots) {
- IFolder sourceFolder = project.getFolder(srcRoot.getDir());
- if (!sourceFolder.exists()) {
- sourceFolder.create(true, true, monitor);
+ IProject project = getProject();
+
+ // Create the source folders
+ TemplateManifest manifest = getManifest();
+ if (manifest != null) {
+ List<SourceRoot> srcRoots = getManifest().getSrcRoots();
+ if (srcRoots != null && !srcRoots.isEmpty()) {
+ for (SourceRoot srcRoot : srcRoots) {
+ IFolder sourceFolder = project.getFolder(srcRoot.getDir());
+ if (!sourceFolder.exists()) {
+ sourceFolder.create(true, true, monitor);
+ }
+
+ entries.add(CoreModel.newSourceEntry(sourceFolder.getFullPath()));
}
-
- entries.add(CoreModel.newSourceEntry(sourceFolder.getFullPath()));
+ } else {
+ entries.add(CoreModel.newSourceEntry(getProject().getFullPath()));
}
- } else {
- entries.add(CoreModel.newSourceEntry(getProject().getFullPath()));
}
- entries.add(CoreModel.newOutputEntry(getProject().getFolder("build").getFullPath(),
- new IPath[] { new Path("**/CMakeFiles/**") }));
+ entries.add(CoreModel.newOutputEntry(getProject().getFolder("build").getFullPath(), //$NON-NLS-1$
+ new IPath[] { new Path("**/CMakeFiles/**") })); //$NON-NLS-1$
CoreModel.getDefault().create(project).setRawPathEntries(entries.toArray(new IPathEntry[entries.size()]),
monitor);
}
diff --git a/build/org.eclipse.cdt.cmake.ui/plugin.xml b/build/org.eclipse.cdt.cmake.ui/plugin.xml
index b0483065a3..042d05e8d1 100644
--- a/build/org.eclipse.cdt.cmake.ui/plugin.xml
+++ b/build/org.eclipse.cdt.cmake.ui/plugin.xml
@@ -37,7 +37,7 @@
</tag>
<template
icon="icons/cmake_logo-main.png"
- id="org.eclipse.cdt.cmake.ui.emptyProjectTemplate"
+ id="org.eclipse.cdt.cmake.ui.newProjectTemplate"
label="CMake Project"
wizard="org.eclipse.cdt.cmake.ui.internal.NewCMakeProjectWizard">
<description>
@@ -50,6 +50,21 @@
id="org.eclipse.cdt.cmake.ui.tag">
</tagReference>
</template>
+ <template
+ icon="icons/cmake_logo-main.png"
+ id="org.eclipse.cdt.cmake.ui.emptyProjectTemplate"
+ label="Empty or Existing CMake Project"
+ wizard="org.eclipse.cdt.cmake.ui.internal.EmptyCMakeProjectWizard">
+ <description>
+ Create a CMake project with no files. Can be used to create one over existing content.
+ </description>
+ <tagReference
+ id="org.eclipse.cdt.ui.cdtTag">
+ </tagReference>
+ <tagReference
+ id="org.eclipse.cdt.cmake.ui.tag">
+ </tagReference>
+ </template>
</extension>
<extension
point="org.eclipse.cdt.launch.coreBuildTab">
diff --git a/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/EmptyCMakeProjectWizard.java b/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/EmptyCMakeProjectWizard.java
new file mode 100644
index 0000000000..9c147750e6
--- /dev/null
+++ b/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/EmptyCMakeProjectWizard.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2016 QNX Software Systems and others.
+ * 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
+ *******************************************************************************/
+package org.eclipse.cdt.cmake.ui.internal;
+
+import org.eclipse.cdt.cmake.core.CMakeProjectGenerator;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tools.templates.core.IGenerator;
+import org.eclipse.tools.templates.ui.TemplateWizard;
+import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
+
+public class EmptyCMakeProjectWizard extends TemplateWizard {
+
+ private WizardNewProjectCreationPage mainPage;
+
+ @Override
+ public void addPages() {
+ mainPage = new WizardNewProjectCreationPage("basicNewProjectPage") { //$NON-NLS-1$
+ @Override
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+ createWorkingSetGroup((Composite) getControl(), getSelection(),
+ new String[] { "org.eclipse.ui.resourceWorkingSetPage" }); //$NON-NLS-1$
+ Dialog.applyDialogFont(getControl());
+ }
+ };
+ mainPage.setTitle("New CMake Project"); //$NON-NLS-1$
+ mainPage.setDescription("Specify properties of new CMake project."); //$NON-NLS-1$
+ this.addPage(mainPage);
+ }
+
+ @Override
+ protected IGenerator getGenerator() {
+ CMakeProjectGenerator generator = new CMakeProjectGenerator(null);
+ generator.setProjectName(mainPage.getProjectName());
+ if (!mainPage.useDefaults()) {
+ generator.setLocationURI(mainPage.getLocationURI());
+ }
+ return generator;
+ }
+
+}

Back to the top