當前位置: 首頁>>代碼示例>>Java>>正文


Java IProjectDescription.setNatureIds方法代碼示例

本文整理匯總了Java中org.eclipse.core.resources.IProjectDescription.setNatureIds方法的典型用法代碼示例。如果您正苦於以下問題:Java IProjectDescription.setNatureIds方法的具體用法?Java IProjectDescription.setNatureIds怎麽用?Java IProjectDescription.setNatureIds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.core.resources.IProjectDescription的用法示例。


在下文中一共展示了IProjectDescription.setNatureIds方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addAsMainNature

import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
public static void addAsMainNature(IProject project, String natureID, IProgressMonitor monitor) throws CoreException{
	if (monitor != null && monitor.isCanceled()) {
		throw new OperationCanceledException();
	}
	if (!project.hasNature(natureID)) {
		IProjectDescription description = project.getDescription();
		String[] natures = description.getNatureIds();
		String[] newNatures = new String[natures.length + 1];
		System.arraycopy(natures, 0, newNatures, 1, natures.length);
		newNatures[0] = natureID;
		description.setNatureIds(newNatures);
		project.setDescription(description, null);
	} else {
		if (monitor != null) {
			monitor.worked(1);
		}
	}
}
 
開發者ID:eclipse,項目名稱:gemoc-studio-modeldebugging,代碼行數:19,代碼來源:AddRemoveGemocSequentialLanguageNatureHandler.java

示例2: createProject

import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
protected void createProject ( final IProgressMonitor monitor ) throws CoreException
{
    monitor.beginTask ( "Create project", 2 );

    final IProject project = this.info.getProject ();

    final IProjectDescription desc = project.getWorkspace ().newProjectDescription ( project.getName () );
    desc.setLocation ( this.info.getProjectLocation () );
    desc.setNatureIds ( new String[] { Constants.PROJECT_NATURE_CONFIGURATION, PROJECT_NATURE_JS } );

    final ICommand jsCmd = desc.newCommand ();
    jsCmd.setBuilderName ( BUILDER_JS_VALIDATOR );

    final ICommand localBuilder = desc.newCommand ();
    localBuilder.setBuilderName ( Constants.PROJECT_BUILDER );

    desc.setBuildSpec ( new ICommand[] { jsCmd, localBuilder } );

    if ( !project.exists () )
    {
        project.create ( desc, new SubProgressMonitor ( monitor, 1 ) );
        project.open ( new SubProgressMonitor ( monitor, 1 ) );
    }
    monitor.done ();
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:26,代碼來源:CreateProjectOperation.java

示例3: createFeatureProject

import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
private void createFeatureProject ( final IProject project, final Map<String, String> properties, final IProgressMonitor monitor ) throws CoreException
{
    monitor.beginTask ( "Creating feature project", 6 );

    final String name = this.pluginId + ".feature"; //$NON-NLS-1$
    final IProjectDescription desc = project.getWorkspace ().newProjectDescription ( name );

    final ICommand featureBuilder = desc.newCommand ();
    featureBuilder.setBuilderName ( "org.eclipse.pde.FeatureBuilder" ); //$NON-NLS-1$

    desc.setNatureIds ( new String[] { "org.eclipse.pde.FeatureNature" } ); //$NON-NLS-1$
    desc.setBuildSpec ( new ICommand[] {
            featureBuilder
    } );

    final IProject newProject = project.getWorkspace ().getRoot ().getProject ( name );
    newProject.create ( desc, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1
    newProject.open ( new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1

    addFilteredResource ( newProject, "pom.xml", getResource ( "feature-pom.xml" ), "UTF-8", properties, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1
    addFilteredResource ( newProject, "feature.xml", getResource ( "feature/feature.xml" ), "UTF-8", properties, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1
    addFilteredResource ( newProject, "feature.properties", getResource ( "feature/feature.properties" ), "ISO-8859-1", properties, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1
    addFilteredResource ( newProject, "build.properties", getResource ( "feature/build.properties" ), "ISO-8859-1", properties, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1

    monitor.done ();
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:27,代碼來源:ClientTemplate.java

示例4: removeGW4ENature

import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
/**
 * Remove the GW4E nature from this project This remove the nature
 * and the GraphWalker libraries from its classpath
 * 
 * @param project
 */
public static void removeGW4ENature(IProject project) {
	try {
		IProjectDescription description = project.getDescription();
		List<String> newNatures = new ArrayList<String>();
		for (String natureId : description.getNatureIds()) {
			if (!NATURE_ID.equals(natureId)) {
				newNatures.add(natureId);
			}
		}
		description.setNatureIds(newNatures.toArray(new String[newNatures.size()]));
		project.setDescription(description, null);
	} catch (CoreException e) {
		ResourceManager.logException(e);
		return;
	}
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:23,代碼來源:GW4ENature.java

示例5: setGW4ENature

import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
/**
 * Set the GW4E Nature to the passed project
 * 
 * @param project
 * @return
 * @throws CoreException
 */
public static IStatus setGW4ENature(IProject project) throws CoreException {
	IProjectDescription description = project.getDescription();
	String[] natures = description.getNatureIds();
	String[] newNatures = new String[natures.length + 1];
	System.arraycopy(natures, 0, newNatures, 0, natures.length);

	// add our id
	newNatures[natures.length] = GW4ENature.NATURE_ID;

	// validate the natures
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	IStatus status = workspace.validateNatureSet(newNatures);

	if (status.getCode() == IStatus.OK) {
		description.setNatureIds(newNatures);
		project.setDescription(description, null);
	}
	return status;
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:27,代碼來源:GW4ENature.java

示例6: switchDiceNature

import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
public static void switchDiceNature(IProject project) throws CoreException {
	IProjectDescription description = project.getDescription();
	if (description == null) {
		return;
	}

	List<String> natures = new ArrayList<>();
	natures.addAll(Arrays.asList(description.getNatureIds()));
	if (natures.contains(DiceProjectNature.ID)) {
		natures.remove(DiceProjectNature.ID);
	} else {
		natures.add(DiceProjectNature.ID);
	}

	description.setNatureIds(natures.toArray(new String[0]));

	project.setDescription(description, new NullProgressMonitor());
}
 
開發者ID:dice-project,項目名稱:DICE-Platform,代碼行數:19,代碼來源:DiceProjectSwitchNatureAction.java

示例7: deactivate

import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
public static void deactivate(IProject project) {
	try {
		IProjectDescription description = project.getDescription();
		String[] natures = description.getNatureIds();
		
		for (int i = 0; i < natures.length; ++i) {
			if (NATURE_ID.equals(natures[i])) {
				// Remove the nature
				String[] newNatures = new String[natures.length - 1];
				System.arraycopy(natures, 0, newNatures, 0, i);
				System.arraycopy(natures, i + 1, newNatures, i, natures.length - i - 1);
				description.setNatureIds(newNatures);
				project.setDescription(description, null);
				return;
			}
		}
	} catch (CoreException e) {
	}
}
 
開發者ID:DarwinSPL,項目名稱:DarwinSPL,代碼行數:20,代碼來源:HymanifestNature.java

示例8: activate

import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
public static void activate(IProject project) {
	try {
		IProjectDescription description = project.getDescription();
		String[] natures = description.getNatureIds();
		
		for (int i = 0; i < natures.length; ++i) {
			if (NATURE_ID.equals(natures[i])) {
				// already active
				return;
			}
		}
		// Add the nature
		String[] newNatures = new String[natures.length + 1];
		System.arraycopy(natures, 0, newNatures, 0, natures.length);
		newNatures[natures.length] = NATURE_ID;
		description.setNatureIds(newNatures);
		project.setDescription(description, null);
	} catch (CoreException e) {
	}
}
 
開發者ID:DarwinSPL,項目名稱:DarwinSPL,代碼行數:21,代碼來源:HyconstraintsNature.java

示例9: initialize

import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
private IProject initialize(String projectName) {
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	IWorkspaceRoot root = workspace.getRoot();
	IProject project = root.getProject(projectName);
	if (!project.exists())
		try {
			project.create(null);
			if (!project.isOpen())
				project.open(null);
			if (!project.hasNature("org.eclipse.xtext.ui.shared.xtextNature")) {
				IProjectDescription description = project.getDescription();
				description.setNatureIds(new String[] { "org.eclipse.xtext.ui.shared.xtextNature" });
				project.setDescription(description, null);
			}
		} catch (CoreException e) {
			e.printStackTrace();
		}
	return project;
}
 
開發者ID:ioanaverebi,項目名稱:Sparrow,代碼行數:20,代碼來源:ModelVisitor.java

示例10: addProjectNature

import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
/**
 * Add a nature to the project.
 * 
 * @param project project
 * @param monitor progress monitor
 * @throws CoreException
 */
public static void addProjectNature(IProject project, IProgressMonitor monitor)
        throws CoreException {

    monitor.subTask(TexlipsePlugin.getResourceString("projectWizardProgressNature"));

    IProjectDescription desc = project.getDescription();
    String[] natures = desc.getNatureIds();
    for (int i = 0; i < natures.length; i++) {
        // don't add if already there
        if (TexlipseNature.NATURE_ID.equals(natures[i])) {
            return;
        }
    }
    
    String[] newNatures = new String[natures.length + 1];
    System.arraycopy(natures, 0, newNatures, 1, natures.length);
    newNatures[0] = TexlipseNature.NATURE_ID;
    desc.setNatureIds(newNatures);
    project.setDescription(desc, monitor);
}
 
開發者ID:eclipse,項目名稱:texlipse,代碼行數:28,代碼來源:TexlipseProjectCreationOperation.java

示例11: createTempProject

import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
/***/
protected URI createTempProject(String projectName) throws CoreException {
	IProjectDescription description = workspace.getWorkspace().newProjectDescription(projectName);
	// deliberately avoid the build command
	description.setNatureIds(new String[] { XtextProjectHelper.NATURE_ID });
	IProject newProject = workspace.getProject(projectName);
	newProject.create(null);
	newProject.open(null);
	newProject.setDescription(description, null);
	return URI.createPlatformResourceURI(projectName, true);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:12,代碼來源:EclipseBasedProjectModelSetup.java

示例12: addNature

import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
public static void addNature(IProjectDescription description)
{
	Set<String> newIds = new LinkedHashSet<>();
	newIds.addAll(Arrays.asList(description.getNatureIds()));
	if( newIds.add(NATURE_ID) )
	{
		description.setNatureIds(newIds.toArray(new String[newIds.size()]));
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:10,代碼來源:JPFJarNature.java

示例13: removeNature

import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
public static void removeNature(IProjectDescription description)
{
	Set<String> newIds = new LinkedHashSet<>();
	newIds.addAll(Arrays.asList(description.getNatureIds()));
	if( newIds.remove(NATURE_ID) )
	{
		description.setNatureIds(newIds.toArray(new String[newIds.size()]));
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:10,代碼來源:JPFProjectNature.java

示例14: addNatureToProject

import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor)
		throws CoreException {
	IProjectDescription description = proj.getDescription();
	String[] prevNatures = description.getNatureIds();
	String[] newNatures = new String[prevNatures.length + 1];
	System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
	newNatures[prevNatures.length] = natureId;
	description.setNatureIds(newNatures);
	proj.setDescription(description, monitor);
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:11,代碼來源:ProjectHelper.java

示例15: createPgDbProject

import org.eclipse.core.resources.IProjectDescription; //導入方法依賴的package包/類
public static PgDbProject createPgDbProject(IProject newProject, URI location)
        throws CoreException {
    if (!newProject.exists()) {
        IProjectDescription desc = newProject.getWorkspace()
                .newProjectDescription(newProject.getName());

        desc.setLocationURI(location);
        desc.setNatureIds(new String[] {NATURE.ID});
        newProject.create(desc, null);
        newProject.open(IResource.BACKGROUND_REFRESH, null);
        newProject.getNature(NATURE.ID).configure();
    }
    return new PgDbProject(newProject);
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:15,代碼來源:PgDbProject.java


注:本文中的org.eclipse.core.resources.IProjectDescription.setNatureIds方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。