Java Code Examples for org.eclipse.core.resources.IProjectDescription

The following are top voted examples for showing how to use org.eclipse.core.resources.IProjectDescription. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: EclipseMinifyBuilder   File: MinifyNature.java   Source Code and License 6 votes vote down vote up
@Override
public void configure() throws CoreException {
	IProjectDescription desc = project.getDescription();
	ICommand[] commands = desc.getBuildSpec();

	for (int i = 0; i < commands.length; ++i) {
		if (commands[i].getBuilderName().equals(MinifyBuilder.BUILDER_ID)) {
			return;
		}
	}

	ICommand[] newCommands = new ICommand[commands.length + 1];
	System.arraycopy(commands, 0, newCommands, 0, commands.length);
	ICommand command = desc.newCommand();
	command.setBuilderName(MinifyBuilder.BUILDER_ID);
	newCommands[newCommands.length - 1] = command;
	desc.setBuildSpec(newCommands);
	project.setDescription(desc, null);
}
 
Example 2
Project: EclipseMinifyBuilder   File: MinifyNature.java   Source Code and License 6 votes vote down vote up
@Override
public void deconfigure() throws CoreException {
	IProjectDescription description = getProject().getDescription();
	ICommand[] commands = description.getBuildSpec();
	for (int i = 0; i < commands.length; ++i) {
		if (commands[i].getBuilderName().equals(MinifyBuilder.BUILDER_ID)) {
			ICommand[] newCommands = new ICommand[commands.length - 1];
			System.arraycopy(commands, 0, newCommands, 0, i);
			System.arraycopy(commands, i + 1, newCommands, i,
					commands.length - i - 1);
			description.setBuildSpec(newCommands);
			project.setDescription(description, null);
			return;
		}
	}
}
 
Example 3
Project: gemoc-studio-modeldebugging   File: GemocSequentialLanguageNature.java   Source Code and License 6 votes vote down vote up
public void configure() throws CoreException {
	IProjectDescription desc = project.getDescription();
	ICommand[] commands = desc.getBuildSpec();

	for (int i = 0; i < commands.length; ++i) {
		if (commands[i].getBuilderName().equals(GemocSequentialLanguageBuilder.BUILDER_ID)) {
			return;
		}
	}

	ICommand[] newCommands = new ICommand[commands.length + 1];
	System.arraycopy(commands, 0, newCommands, 0, commands.length);
	ICommand command = desc.newCommand();
	command.setBuilderName(GemocSequentialLanguageBuilder.BUILDER_ID);
	newCommands[newCommands.length - 1] = command;
	desc.setBuildSpec(newCommands);
	project.setDescription(desc, null);
}
 
Example 4
Project: gemoc-studio-modeldebugging   File: AddRemoveGemocSequentialLanguageNatureHandler.java   Source Code and License 6 votes vote down vote up
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);
		}
	}
}
 
Example 5
Project: neoscada   File: CreateProjectOperation.java   Source Code and License 6 votes vote down vote up
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 ();
}
 
Example 6
Project: neoscada   File: ClientTemplate.java   Source Code and License 6 votes vote down vote up
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 ();
}
 
Example 7
Project: convertigo-eclipse   File: ConvertigoPlugin.java   Source Code and License 6 votes vote down vote up
public IProject createProjectPluginResource(String projectName, IProgressMonitor monitor) throws CoreException {
	IWorkspace myWorkspace = ResourcesPlugin.getWorkspace();
	IWorkspaceRoot myWorkspaceRoot = myWorkspace.getRoot();
	IProject resourceProject = myWorkspaceRoot.getProject(projectName);
	
	if (!resourceProject.exists()) {		
		if(myWorkspaceRoot.getLocation().toFile().equals(new Path(Engine.PROJECTS_PATH).toFile())){
			logDebug("createProjectPluginResource : project is in the workspace folder");
			
			resourceProject.create(monitor);
		}else{
			logDebug("createProjectPluginResource: project isn't in the workspace folder");
	
			IPath projectPath = new Path(Engine.PROJECTS_PATH + "/" + projectName).makeAbsolute();
			IProjectDescription description = myWorkspace.newProjectDescription(projectName);
			description.setLocation(projectPath);
			resourceProject.create(description, monitor);
		}
	}
	
	return resourceProject;
}
 
Example 8
Project: Equella   File: JPFManifestBuilder.java   Source Code and License 6 votes vote down vote up
public static void removeBuilderFromProject(IProjectDescription description)
{
	// Look for builder.
	int index = -1;
	ICommand[] cmds = description.getBuildSpec();
	for( int j = 0; j < cmds.length; j++ )
	{
		if( cmds[j].getBuilderName().equals(BUILDER_ID) )
		{
			index = j;
			break;
		}
	}
	if( index == -1 )
		return;

	// Remove builder from project.
	List<ICommand> newCmds = new ArrayList<ICommand>();
	newCmds.addAll(Arrays.asList(cmds));
	newCmds.remove(index);
	description.setBuildSpec(newCmds.toArray(new ICommand[newCmds.size()]));
}
 
Example 9
Project: Equella   File: JPFProjectNature.java   Source Code and License 6 votes vote down vote up
@Override
public void configure() throws CoreException
{
	IProjectDescription description = project.getDescription();
	JPFManifestBuilder.addBuilderToProject(description);
	project.setDescription(description, null);
	JPFClasspathContainer.addToProject(JavaCore.create(project));
	new Job("Check JPF Manifest")
	{
		@Override
		protected IStatus run(IProgressMonitor monitor)
		{
			try
			{
				project.build(IncrementalProjectBuilder.FULL_BUILD, JPFManifestBuilder.BUILDER_ID, null, monitor);
			}
			catch( CoreException e )
			{
				JPFClasspathLog.logError(e);
			}
			return Status.OK_STATUS;
		}
	}.schedule();
}
 
Example 10
Project: gw4e.project   File: GW4ENature.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
	}
}
 
Example 11
Project: gw4e.project   File: GW4ENature.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
}
 
Example 12
Project: gw4e.project   File: ClasspathManager.java   Source Code and License 6 votes vote down vote up
/**
 * Set the GW4E builder
 * 
 * @param project
 * @param monitor
 * @throws CoreException
 */
public static void setBuilder(IProject project, IProgressMonitor monitor) throws CoreException {
	IProjectDescription desc = project.getDescription();
	ICommand[] commands = desc.getBuildSpec();

	for (int i = 0; i < commands.length; ++i) {
		if (commands[i].getBuilderName().equals(GW4EBuilder.BUILDER_ID)) {
			return;
		}
	}

	ICommand[] newCommands = new ICommand[commands.length + 1];
	System.arraycopy(commands, 0, newCommands, 0, commands.length);
	ICommand command = desc.newCommand();
	command.setBuilderName(GW4EBuilder.BUILDER_ID);
	newCommands[newCommands.length - 1] = command;
	desc.setBuildSpec(newCommands);
	project.setDescription(desc, null);
}
 
Example 13
Project: gw4e.project   File: ClasspathManager.java   Source Code and License 6 votes vote down vote up
/**
 * Remove the GW4E builder
 * 
 * @param project
 * @param monitor
 * @throws CoreException
 */
public static void unsetBuilder(IProject project, IProgressMonitor monitor) throws CoreException {
	IProjectDescription description = project.getDescription();
	ICommand[] commands = description.getBuildSpec();
	for (int i = 0; i < commands.length; ++i) {
		if (commands[i].getBuilderName().equals(GW4EBuilder.BUILDER_ID)) {
			ICommand[] newCommands = new ICommand[commands.length - 1];
			System.arraycopy(commands, 0, newCommands, 0, i);
			System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1);
			description.setBuildSpec(newCommands);
			project.setDescription(description, null);
			GW4EBuilder.removeProjectProblemMarker(project, monitor);
			return;
		}
	}
}
 
Example 14
Project: gw4e.project   File: ResourceManager.java   Source Code and License 6 votes vote down vote up
/**
 * Test whether the project has the passed nature
 * 
 * @param receiver
 * @param nature
 * @return
 */
public static boolean hasNature(Object receiver, String nature) {
	IProject project = JDTManager.toJavaProject(receiver);
	if (project == null || !project.isOpen())
		return false;
	IProjectDescription description;
	try {
		description = project.getDescription();
	} catch (CoreException e) {
		ResourceManager.logException(e);
		return false;
	}
	String[] natures = description.getNatureIds();
	for (int i = 0; i < natures.length; i++) {
		if (nature.equalsIgnoreCase(natures[i]))
			return true;
	}
	return false;
}
 
Example 15
Project: gw4e.project   File: ClasspathManagerTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testUnsetBuilder() throws Exception {
	IJavaProject p = ProjectHelper.getProject(PROJECT_NAME);
	ClasspathManager.setBuilder(p.getProject(), null);
	IProjectDescription desc = p.getProject().getDescription();
	ICommand[] commands = desc.getBuildSpec();
	boolean found = false;
	for (int i = 0; i < commands.length; ++i) {
		if (commands[i].getBuilderName().equals(GW4EBuilder.BUILDER_ID)) {
			found=true;
		}
	}
	assertTrue(found);
	ClasspathManager.unsetBuilder(p.getProject(), null);
	desc = p.getProject().getDescription();
	commands = desc.getBuildSpec();
	found = false;
	for (int i = 0; i < commands.length; ++i) {
		if (commands[i].getBuilderName().equals(GW4EBuilder.BUILDER_ID)) {
			found=true;
		}
	}
	assertFalse(found);
}
 
Example 16
Project: pgcodekeeper   File: AddBuilder.java   Source Code and License 6 votes vote down vote up
public static void addBuilder(final IProject project) {
    try {
        // verify already registered builders
        if (hasBuilder(project)) {
            // already enabled
            return;
        }
        // add builder to project properties
        IProjectDescription description = project.getDescription();
        final ICommand buildCommand = description.newCommand();
        buildCommand.setBuilderName(BUILDER.ID);

        final List<ICommand> commands = new ArrayList<ICommand>();
        commands.addAll(Arrays.asList(description.getBuildSpec()));
        commands.add(buildCommand);

        description.setBuildSpec(commands.toArray(new ICommand[commands.size()]));
        project.setDescription(description, null);
    } catch (final CoreException e) {
        Log.log(Log.LOG_ERROR, "Cannot add builder", e); //$NON-NLS-1$
    }
}
 
Example 17
Project: pgcodekeeper   File: RemoveBuilder.java   Source Code and License 6 votes vote down vote up
public static void removeBuilder(final IProject project) {
    try {
        final IProjectDescription description = project
                .getDescription();
        final List<ICommand> commands = new ArrayList<ICommand>();
        commands.addAll(Arrays.asList(description.getBuildSpec()));

        for (final ICommand buildSpec : description.getBuildSpec()) {
            if (BUILDER.ID.equals(buildSpec.getBuilderName())) {
                // remove builder
                commands.remove(buildSpec);
            }
        }

        description.setBuildSpec(commands.toArray(new ICommand[commands.size()]));
        project.setDescription(description, null);
    } catch (final CoreException e) {
        Log.log(Log.LOG_ERROR, "Cannot remove builder", e); //$NON-NLS-1$
    }
}
 
Example 18
Project: gemoc-studio   File: AbstractProjectNature.java   Source Code and License 6 votes vote down vote up
protected void addBuilder(String builderId) throws CoreException 
{
	IProjectDescription desc = _project.getDescription();
	ICommand[] commands = desc.getBuildSpec();

	for (int i = 0; i < commands.length; ++i) {
		if (commands[i].getBuilderName().equals(builderId)) {
			return;
		}
	}

	ICommand[] newCommands = new ICommand[commands.length + 1];
	System.arraycopy(commands, 0, newCommands, 0, commands.length);
	ICommand command = desc.newCommand();
	command.setBuilderName(builderId);
	newCommands[newCommands.length - 1] = command;
	desc.setBuildSpec(newCommands);
	_project.setDescription(desc, null);
}
 
Example 19
Project: gemoc-studio   File: AbstractProjectNature.java   Source Code and License 6 votes vote down vote up
protected void removeBuilder(String builderId) throws CoreException
{
	IProjectDescription description = getProject().getDescription();
	ICommand[] commands = description.getBuildSpec();
	for (int i = 0; i < commands.length; ++i) {
		if (commands[i].getBuilderName().equals(builderId)) {
			ICommand[] newCommands = new ICommand[commands.length - 1];
			System.arraycopy(commands, 0, newCommands, 0, i);
			System.arraycopy(commands, i + 1, newCommands, i,
					commands.length - i - 1);
			description.setBuildSpec(newCommands);
			_project.setDescription(description, null);			
			return;
		}
	}
}
 
Example 20
Project: visuflow-plugin   File: VisuFlowNature.java   Source Code and License 6 votes vote down vote up
@Override
public void configure() throws CoreException {
	IProjectDescription desc = project.getDescription();
	ICommand[] commands = desc.getBuildSpec();

	for (int i = 0; i < commands.length; ++i) {
		if (commands[i].getBuilderName().equals(JimpleBuilder.BUILDER_ID)) {
			return;
		}
	}

	ICommand[] newCommands = new ICommand[commands.length + 1];
	System.arraycopy(commands, 0, newCommands, 0, commands.length);
	ICommand command = desc.newCommand();
	command.setBuilderName(JimpleBuilder.BUILDER_ID);
	newCommands[newCommands.length - 1] = command;
	desc.setBuildSpec(newCommands);
	project.setDescription(desc, null);
}
 
Example 21
Project: visuflow-plugin   File: VisuFlowNature.java   Source Code and License 6 votes vote down vote up
@Override
public void deconfigure() throws CoreException {
	IProjectDescription description = getProject().getDescription();
	ICommand[] commands = description.getBuildSpec();
	for (int i = 0; i < commands.length; ++i) {
		if (commands[i].getBuilderName().equals(JimpleBuilder.BUILDER_ID)) {
			ICommand[] newCommands = new ICommand[commands.length - 1];
			System.arraycopy(commands, 0, newCommands, 0, i);
			System.arraycopy(commands, i + 1, newCommands, i,
					commands.length - i - 1);
			description.setBuildSpec(newCommands);
			project.setDescription(description, null);
			return;
		}
	}
}
 
Example 22
Project: ClassCleaner   File: ClassCleanerNature.java   Source Code and License 6 votes vote down vote up
@Override
public void configure() throws CoreException {
	IProjectDescription desc = project.getDescription();
	ICommand[] commands = desc.getBuildSpec();

	for (int i = 0; i < commands.length; ++i) {
		if (commands[i].getBuilderName().equals(ClassCleanerBuilder.BUILDER_ID)) {
			return;
		}
	}

	ICommand[] newCommands = new ICommand[commands.length + 1];
	System.arraycopy(commands, 0, newCommands, 0, commands.length);
	ICommand command = desc.newCommand();
	command.setBuilderName(ClassCleanerBuilder.BUILDER_ID);
	newCommands[newCommands.length - 1] = command;
	desc.setBuildSpec(newCommands);
	project.setDescription(desc, null);
}
 
Example 23
Project: ClassCleaner   File: ClassCleanerNature.java   Source Code and License 6 votes vote down vote up
@Override
public void deconfigure() throws CoreException {
	IProjectDescription description = getProject().getDescription();
	ICommand[] commands = description.getBuildSpec();
	for (int i = 0; i < commands.length; ++i) {
		if (commands[i].getBuilderName().equals(ClassCleanerBuilder.BUILDER_ID)) {
			ICommand[] newCommands = new ICommand[commands.length - 1];
			System.arraycopy(commands, 0, newCommands, 0, i);
			System.arraycopy(commands, i + 1, newCommands, i,
					commands.length - i - 1);
			description.setBuildSpec(newCommands);
			project.setDescription(description, null);
			return;
		}
	}
}
 
Example 24
Project: jason-eclipse-plugin   File: JasonNature.java   Source Code and License 6 votes vote down vote up
@Override 
public void configure() throws CoreException {
	IProjectDescription desc = project.getDescription();
	ICommand[] commands = desc.getBuildSpec();

	for (int i = 0; i < commands.length; ++i) {
		if (commands[i].getBuilderName().equals(JasonBuilder.BUILDER_ID)) {
			return;
		}
	}
	
	ICommand[] newCommands = new ICommand[commands.length + 1];
	System.arraycopy(commands, 0, newCommands, 1, commands.length);
	ICommand command = desc.newCommand();
	command.setBuilderName(JasonBuilder.BUILDER_ID);
	newCommands[0] = command;
	desc.setBuildSpec(newCommands);
	project.setDescription(desc, null);
}
 
Example 25
Project: jason-eclipse-plugin   File: JasonNature.java   Source Code and License 6 votes vote down vote up
@Override
public void deconfigure() throws CoreException {
	IProjectDescription description = getProject().getDescription();
	ICommand[] commands = description.getBuildSpec();
	for (int i = 0; i < commands.length; ++i) {
		if (commands[i].getBuilderName().equals(JasonBuilder.BUILDER_ID)) {
			ICommand[] newCommands = new ICommand[commands.length - 1];
			System.arraycopy(commands, 0, newCommands, 0, i);
			System.arraycopy(commands, i + 1, newCommands, i,
					commands.length - i - 1);
			description.setBuildSpec(newCommands);
			project.setDescription(description, null);			
			return;
		}
	}
}
 
Example 26
Project: egradle   File: EclipseResourceHelper.java   Source Code and License 6 votes vote down vote up
public IProject createLinkedProject(String projectName, Plugin plugin, IPath linkPath) throws CoreException {
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	IProject project = workspace.getRoot().getProject(projectName);

	IProjectDescription desc = workspace.newProjectDescription(projectName);
	File file = getFileInPlugin(plugin, linkPath);
	IPath projectLocation = new Path(file.getAbsolutePath());
	if (Platform.getLocation().equals(projectLocation))
		projectLocation = null;
	desc.setLocation(projectLocation);

	project.create(desc, NULL_MONITOR);
	if (!project.isOpen())
		project.open(NULL_MONITOR);

	return project;
}
 
Example 27
Project: egradle   File: IDEUtil.java   Source Code and License 6 votes vote down vote up
/**
 * Imports a project by given description file (.project). If a project
 * already exists in workspace with same name it will be automatically
 * deleted (without content delete)
 * 
 * @param projectFileOrFolder
 *            file (.project) or the folder containing it
 * @param monitor
 * @return project, never <code>null</code>
 * @throws CoreException
 */
public static IProject importProject(File projectFileOrFolder, IProgressMonitor monitor) throws CoreException {
	File projectFile = null;
	if (projectFileOrFolder.isDirectory()) {
		projectFile = new File(projectFileOrFolder, GradleImportScanner.ECLIPSE_PROJECTFILE_NAME);
	} else {
		projectFile = projectFileOrFolder;
	}
	Path path = new Path(projectFile.getAbsolutePath());
	IProjectDescription description = ResourcesPlugin.getWorkspace().loadProjectDescription(path);
	IProject project = getProject(description.getName());
	/*
	 * always delete project if already existing - but without content
	 * delete
	 */
	project.delete(false, true, monitor);
	project.create(description, monitor);
	return project;
}
 
Example 28
Project: egradle   File: VirtualRootProjectNature.java   Source Code and License 6 votes vote down vote up
@Override
public void configure() throws CoreException {
	IProjectDescription desc = project.getDescription();
	ICommand[] commands = desc.getBuildSpec();

	for (int i = 0; i < commands.length; ++i) {
		if (commands[i].getBuilderName().equals(VirtualRootNewFilesToRealRootProjectBuilder.BUILDER_ID)) {
			return;
		}
	}

	ICommand[] newCommands = new ICommand[commands.length + 1];
	System.arraycopy(commands, 0, newCommands, 0, commands.length);
	ICommand command = desc.newCommand();
	command.setBuilderName(VirtualRootNewFilesToRealRootProjectBuilder.BUILDER_ID);
	newCommands[newCommands.length - 1] = command;
	desc.setBuildSpec(newCommands);
	project.setDescription(desc, null);
}
 
Example 29
Project: LibertyEiffel-Eclipse-Plugin   File: LEProjectSupport.java   Source Code and License 6 votes vote down vote up
private static IProject createBaseProject(String projectName, URI location) {
	IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
	
	if (!newProject.exists()) {
		URI projectLocation = location;
		IProjectDescription description = newProject.getWorkspace().newProjectDescription(newProject.getName());
		if (location != null && ResourcesPlugin.getWorkspace().getRoot().getLocationURI().equals(location)) {
			projectLocation = null;
		}
		
		description.setLocationURI(projectLocation);
		try {
			newProject.create(description, null);
			if (!newProject.isOpen()) {
				newProject.open(null);
			}
		} catch (CoreException e) {
			e.printStackTrace();
		}
	}
	
	return newProject;
}
 
Example 30
Project: eclipse   File: BazelProjectSupport.java   Source Code and License 6 votes vote down vote up
private static IProject createBaseProject(String projectName, URI location) {
  IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);

  if (!newProject.exists()) {
    URI projectLocation = location;
    IProjectDescription desc =
        newProject.getWorkspace().newProjectDescription(newProject.getName());
    if (location != null
        && ResourcesPlugin.getWorkspace().getRoot().getLocationURI().equals(location)) {
      projectLocation = null;
    }

    desc.setLocationURI(projectLocation);
    try {
      newProject.create(desc, null);
      if (!newProject.isOpen()) {
        newProject.open(null);
      }
    } catch (CoreException e) {
      e.printStackTrace();
    }
  }

  return newProject;
}
 
Example 31
Project: DarwinSPL   File: HyexpressionNature.java   Source Code and License 6 votes vote down vote up
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) {
	}
}
 
Example 32
Project: DarwinSPL   File: HyexpressionNature.java   Source Code and License 6 votes vote down vote up
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) {
	}
}
 
Example 33
Project: DarwinSPL   File: HyexpressionNature.java   Source Code and License 6 votes vote down vote up
public void deconfigure() throws CoreException {
	IProjectDescription description = getProject().getDescription();
	ICommand[] commands = description.getBuildSpec();
	ICommand[] newCommands = commands;
	for (int j = 0; j < BUILDER_IDS.length; j++) {
		for (int i = 0; i < newCommands.length; ++i) {
			if (newCommands[i].getBuilderName().equals(BUILDER_IDS[j])) {
				ICommand[] tempCommands = new ICommand[newCommands.length - 1];
				System.arraycopy(newCommands, 0, tempCommands, 0, i);
				System.arraycopy(newCommands, i + 1, tempCommands, i, newCommands.length - i - 1);
				newCommands = tempCommands;
				break;
			}
		}
	}
	if (newCommands != commands) {
		description.setBuildSpec(newCommands);
	}
}
 
Example 34
Project: DarwinSPL   File: HymanifestNature.java   Source Code and License 6 votes vote down vote up
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) {
	}
}
 
Example 35
Project: DarwinSPL   File: HymanifestNature.java   Source Code and License 6 votes vote down vote up
public void deconfigure() throws CoreException {
	IProjectDescription description = getProject().getDescription();
	ICommand[] commands = description.getBuildSpec();
	ICommand[] newCommands = commands;
	for (int j = 0; j < BUILDER_IDS.length; j++) {
		for (int i = 0; i < newCommands.length; ++i) {
			if (newCommands[i].getBuilderName().equals(BUILDER_IDS[j])) {
				ICommand[] tempCommands = new ICommand[newCommands.length - 1];
				System.arraycopy(newCommands, 0, tempCommands, 0, i);
				System.arraycopy(newCommands, i + 1, tempCommands, i, newCommands.length - i - 1);
				newCommands = tempCommands;
				break;
			}
		}
	}
	if (newCommands != commands) {
		description.setBuildSpec(newCommands);
	}
}
 
Example 36
Project: DarwinSPL   File: HymappingNature.java   Source Code and License 6 votes vote down vote up
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) {
	}
}
 
Example 37
Project: DarwinSPL   File: HymappingNature.java   Source Code and License 6 votes vote down vote up
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) {
	}
}
 
Example 38
Project: DarwinSPL   File: HymappingNature.java   Source Code and License 6 votes vote down vote up
public void deconfigure() throws CoreException {
	IProjectDescription description = getProject().getDescription();
	ICommand[] commands = description.getBuildSpec();
	ICommand[] newCommands = commands;
	for (int j = 0; j < BUILDER_IDS.length; j++) {
		for (int i = 0; i < newCommands.length; ++i) {
			if (newCommands[i].getBuilderName().equals(BUILDER_IDS[j])) {
				ICommand[] tempCommands = new ICommand[newCommands.length - 1];
				System.arraycopy(newCommands, 0, tempCommands, 0, i);
				System.arraycopy(newCommands, i + 1, tempCommands, i, newCommands.length - i - 1);
				newCommands = tempCommands;
				break;
			}
		}
	}
	if (newCommands != commands) {
		description.setBuildSpec(newCommands);
	}
}
 
Example 39
Project: DarwinSPL   File: HyconstraintsNature.java   Source Code and License 6 votes vote down vote up
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) {
	}
}
 
Example 40
Project: DarwinSPL   File: HyconstraintsNature.java   Source Code and License 6 votes vote down vote up
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) {
	}
}