1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

Added template process to add nature. Added Qt nature.

This commit is contained in:
Doug Schaefer 2013-01-17 15:20:49 -05:00
parent 7bbf2d8511
commit 98e5959c90
7 changed files with 123 additions and 1 deletions

View file

@ -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">

View file

@ -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);
}
}
}

View file

@ -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

View file

@ -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

View file

@ -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>

View file

@ -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;
}
}

View file

@ -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>