Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] problem add nature project to a plugin cdt

Hello,
     when I execute my plugin, the nature project I defined was not added to my project. thank you very much for your help!
plugin.xml:
<configuration
               artifactExtension="axf"
               cleanCommand="cleanall"
               errorParsers="ARMErrorParser"
               id="com.xxx.cv.configurationRVDS2.2"
               name="RVDS2.2 Configuration"
               parent="org.eclipse.cdt.build.core.prefbase.cfg">
            <toolChain
                  configurationEnvironmentSupplier="com.xxx.cv.EnvVar2_2"
                  id="com.xxx.cv.toolChainRVDS2.2"
                  isAbstract="false"
                  name="RVDS 2.2 tool chain"
                  superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
               <targetPlatform
                     id="com.xxx.cv.targetPlatform1"
                     isAbstract="false">
               </targetPlatform>
               <builder
                     command="gnumake"
                     id="com.xxx.cv.builderRVDS2.2"
                     isAbstract="false"
                     isVariableCaseSensitive="false"
                     name="RVDS2.2 builder"
                     superClass="org.eclipse.cdt.build.core.settings.default.builder">
               </builder>
               <tool
                     id="com.xxx.cv.tool1"
                     name="GNU C"
                     superClass="org.eclipse.cdt.build.core.settings.holder">
                  <inputType
                        id="com.xxx.cv.inputTypeRVDS2.2"
                        name="RVDS2.2  inputType"
                        sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader"
                        superClass="org.eclipse.cdt.build.core.settings.holder.inType">
                  </inputType>
     <option
           id="com.xxx.cv.optionRVDS2.2"
           isAbstract="false"
           name="Include paths RVDS2.2"
           resourceFilter="all"
           superClass="org.eclipse.cdt.build.core.settings.holder.incpaths"
           valueType="includePath">
        <listOptionValue
              builtIn="false"
              value="X:\include\windows">
        </listOptionValue>
        </listOptionValue>
    <enablement
          type="ALL">
       <hasNature
             natureId="com.xxx.cv.NatureLinkedRessources">
       </hasNature>
    </enablement>
     </option>
               </tool>
            </toolChain>
         </configuration>
      </projectType>
   </extension>
   <extension
         id="ARMErrorParser"
         name="ARM Error Parser"
         point="org.eclipse.cdt.core.ErrorParser">
      <errorparser
            class="com.xxx.cv.ARMErrorParser">
      </errorparser>
   </extension>
   <extension
         id="com.xxx.cv.NatureLinkedRessources"
         name="NatureLinkedRessources"
         point="org.eclipse.core.resources.natures">
      <runtime>
         <run
               class="com.xxx.cv.ProjectNature1">
         </run>
      </runtime>
      <requires-nature
            id="com.xxx.cv.NatureLinkedRessources">
      </requires-nature>
      <options
            allowLinking="true">
      </options>
   </extension>
</plugin>

ProjectNature1.java:
package com.xxx.cv;

import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;

public class ProjectNature1 implements IProjectNature {
public static final String NATURE_ID = "com.xxx.cv.NatureLinkedRessources";
private IProject project;

@Override
public void configure() throws CoreException {
try {
     IProjectDescription description = project.getDescription();
     String[] natures = description.getNatureIds();
     String[] newNatures = new String[natures.length + 1];
     System.arraycopy(natures, 0, newNatures, 0, natures.length);
     newNatures[natures.length] = "com.xxx.cv.NatureLinkedRessources";
     description.setNatureIds(newNatures);
     project.setDescription(description, null);
  } catch (CoreException e) {
     // Something went wrong
  }
  addLinks("Link1","Z:\\S\\_base");
  addLinks("Link2","Z:\\S\\_lib\\_src");

}


public void addLinks(String linkfile, String linkPath) {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IFolder link = project.getFolder(linkfile);
IPath location = new Path(linkPath);
if (workspace.validateLinkLocation(link, location).isOK()) {
try {
link.createLink(location, IResource.NONE, null);
} catch (CoreException e) {
e.printStackTrace();
}
} else {
// invalid location, throw an exception or warn user
}

}


@Override
public void deconfigure() throws CoreException {
// TODO Auto-generated method stub
}


@Override
public IProject getProject() {
// TODO Auto-generated method stub
return this.project;
}


@Override
public void setProject(IProject project) {
this.project = project;
}

}



Hotmail : un service de messagerie gratuit, fiable et complet Profitez-en

Back to the top