Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2013-01-17 20:20:49 +0000
committerDoug Schaefer2013-01-17 20:27:47 +0000
commit98e5959c90e5bd3484445844e8e50478253b2a24 (patch)
tree383284126cf5f43f126ad6951a7df0ec61a58d72
parent7bbf2d8511e8e1fc866f5b3d3edd4460f6e5b0f8 (diff)
downloadorg.eclipse.cdt-98e5959c90e5bd3484445844e8e50478253b2a24.tar.gz
org.eclipse.cdt-98e5959c90e5bd3484445844e8e50478253b2a24.tar.xz
org.eclipse.cdt-98e5959c90e5bd3484445844e8e50478253b2a24.zip
Added template process to add nature. Added Qt nature.
-rw-r--r--core/org.eclipse.cdt.core/plugin.xml10
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/AddNature.java56
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/messages.properties2
-rw-r--r--qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF1
-rw-r--r--qt/org.eclipse.cdt.qt.core/plugin.xml9
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtNature.java40
-rw-r--r--qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/template.xml6
7 files changed, 123 insertions, 1 deletions
diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml
index d65aa20c4f..7cd1e698f0 100644
--- a/core/org.eclipse.cdt.core/plugin.xml
+++ b/core/org.eclipse.cdt.core/plugin.xml
@@ -771,6 +771,16 @@
</baseType>
</complexArray>
</processType>
+ <processType
+ name="AddNature"
+ processRunner="org.eclipse.cdt.core.templateengine.process.processes.AddNature">
+ <simple
+ name="projectName">
+ </simple>
+ <simple
+ name="natureId">
+ </simple>
+ </processType>
</extension>
<extension
point="org.eclipse.cdt.core.CProjectDescriptionStorage">
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/AddNature.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/AddNature.java
new file mode 100644
index 0000000000..70e2d18cd8
--- /dev/null
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/AddNature.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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
+ *
+ * Contributors:
+ * Doug Schaefer (QNX) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.templateengine.process.processes;
+
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.core.templateengine.TemplateCore;
+import org.eclipse.cdt.core.templateengine.process.ProcessArgument;
+import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
+import org.eclipse.cdt.core.templateengine.process.ProcessRunner;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * @author dschaefer
+ *
+ */
+public class AddNature extends ProcessRunner {
+
+ @Override
+ public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {
+ IProject project = null;
+ String natureId = null;
+
+ for (ProcessArgument arg : args) {
+ String argName = arg.getName();
+ if (argName.equals("projectName")) //$NON-NLS-1$
+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(arg.getSimpleValue());
+ else if (argName.equals("natureId")) //$NON-NLS-1$
+ natureId = arg.getSimpleValue();
+ }
+
+ if (project == null)
+ throw new ProcessFailureException(getProcessMessage(processId, IStatus.ERROR, Messages.getString("AddNature.noProject"))); //$NON-NLS-1$
+
+ if (natureId == null)
+ throw new ProcessFailureException(getProcessMessage(processId, IStatus.ERROR, Messages.getString("AddNature.noNature"))); //$NON-NLS-1$
+
+ try {
+ CProjectNature.addNature(project, natureId, monitor);
+ } catch (CoreException e) {
+ throw new ProcessFailureException(e);
+ }
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/messages.properties b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/messages.properties
index d100e9797d..ad8ca201f2 100644
--- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/messages.properties
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/messages.properties
@@ -55,3 +55,5 @@ Append.0=Add File failure: template source not found:
Append.1=Copy failure: template source not found:
Append.3=Copy failure: cannot read template source:
Append.4=Append failure: failed while trying to append contents.
+AddNature.noProject=Add nature failure: projectName not specified
+AddNature.noNature=Add nature failure: nature not specified
diff --git a/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF b/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF
index 552ea94b6c..b4ca9e8d54 100644
--- a/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF
+++ b/qt/org.eclipse.cdt.qt.core/META-INF/MANIFEST.MF
@@ -6,6 +6,7 @@ Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.eclipse.cdt.qt.core.Activator
Bundle-Vendor: Eclipse CDT
Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.core.resources;bundle-version="3.8.100",
org.eclipse.cdt.core
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
diff --git a/qt/org.eclipse.cdt.qt.core/plugin.xml b/qt/org.eclipse.cdt.qt.core/plugin.xml
index d0ab3f8001..959e78450a 100644
--- a/qt/org.eclipse.cdt.qt.core/plugin.xml
+++ b/qt/org.eclipse.cdt.qt.core/plugin.xml
@@ -41,4 +41,13 @@
priority="normal">
</content-type>
</extension>
+ <extension
+ id="qtNature"
+ point="org.eclipse.core.resources.natures">
+ <runtime>
+ <run
+ class="org.eclipse.cdt.qt.core.QtNature">
+ </run>
+ </runtime>
+ </extension>
</plugin>
diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtNature.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtNature.java
new file mode 100644
index 0000000000..f58e2cd190
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtNature.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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
+ *
+ * Contributors:
+ * Doug Schaefer (QNX) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.qt.core;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.runtime.CoreException;
+
+public class QtNature implements IProjectNature {
+ public static final String ID = "org.eclipse.cdt.qt.core.qtNature";
+
+ private IProject project;
+
+ @Override
+ public void configure() throws CoreException {
+ }
+
+ @Override
+ public void deconfigure() throws CoreException {
+ }
+
+ @Override
+ public IProject getProject() {
+ return project;
+ }
+
+ @Override
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
+}
diff --git a/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/template.xml b/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/template.xml
index c80a589e17..58bdd9e8b0 100644
--- a/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/template.xml
+++ b/qt/org.eclipse.cdt.qt.core/templates/project/helloWorld/qtQuick2/template.xml
@@ -56,6 +56,10 @@
</element>
</complex-array>
</process>
+
+ <process type="org.eclipse.cdt.core.AddNature">
+ <simple name="projectName" value="$(projectName)"/>
+ <simple name="natureId" value="org.eclipse.cdt.qt.core.qtNature"/>
+ </process>
</template>
-

Back to the top