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

The following examples show how to use org.eclipse.core.resources.IProjectDescription. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
/**
 * Helper method to enable the given nature for the project.
 * 
 * @throws CoreException
 *           an error while setting the nature occured
 */
private void enableNature() throws CoreException {

  // get the description
  IProjectDescription desc = mProject.getDescription();

  // copy existing natures and add the nature
  String[] natures = desc.getNatureIds();

  String[] newNatures = new String[natures.length + 1];
  System.arraycopy(natures, 0, newNatures, 0, natures.length);
  newNatures[natures.length] = mNatureId;

  // set natures
  desc.setNatureIds(newNatures);
  mProject.setDescription(desc, mMonitor);
}
 
Example 2
/**
 * Helper method to disable the given nature for the project.
 * 
 * @throws CoreException
 *           an error while removing the nature occured
 */
private void disableNature() throws CoreException {

  IProjectDescription desc = mProject.getDescription();
  String[] natures = desc.getNatureIds();

  // remove given nature from the array
  List<String> newNaturesList = new ArrayList<>();
  for (int i = 0; i < natures.length; i++) {
    if (!mNatureId.equals(natures[i])) {
      newNaturesList.add(natures[i]);
    }
  }

  String[] newNatures = newNaturesList.toArray(new String[newNaturesList.size()]);

  // set natures
  desc.setNatureIds(newNatures);
  mProject.setDescription(desc, mMonitor);
}
 
Example 3
/**
 * Update the FindBugs command in the build spec (replace existing one if
 * present, add one first if none).
 */
private void setFindBugsCommand(IProjectDescription description, ICommand newCommand) throws CoreException {
    ICommand[] oldCommands = description.getBuildSpec();
    ICommand oldFindBugsCommand = getFindBugsCommand(description);
    ICommand[] newCommands;
    if (oldFindBugsCommand == null) {
        // Add the FindBugs build spec AFTER all other builders
        newCommands = new ICommand[oldCommands.length + 1];
        System.arraycopy(oldCommands, 0, newCommands, 0, oldCommands.length);
        newCommands[oldCommands.length] = newCommand;
    } else {
        for (int i = 0, max = oldCommands.length; i < max; i++) {
            if (oldCommands[i] == oldFindBugsCommand) {
                oldCommands[i] = newCommand;
                break;
            }
        }
        newCommands = oldCommands;
    }
    // Commit the spec change into the project
    description.setBuildSpec(newCommands);
    getProject().setDescription(description, null);
}
 
Example 4
Source Project: neoscada   Source File: CreateProjectOperation.java    License: Eclipse Public License 1.0 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 5
/**
 * Removes the given builder from the build spec for the given project.
 */
protected void removeFromBuildSpec(String builderID) throws CoreException {

	IProjectDescription description = this.project.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);
			this.project.setDescription(description, null);
			return;
		}
	}
}
 
Example 6
Source Project: CogniCrypt   Source File: UserJavaProject.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @param sourceProject The name of the project to be cloned
 * @param cloneName The name of the cloned project
 * @return a cloned project
 * @throws CoreException
 */

public static IProject cloneProject(final String sourceProject) throws CoreException {
	final IProgressMonitor m = new NullProgressMonitor();
	final IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
	final IProject project = workspaceRoot.getProject(sourceProject);
	final IProjectDescription projectDescription = project.getDescription();
	final String cloneName = sourceProject + "_copy";
	// create clone project in workspace
	final IProjectDescription cloneDescription = workspaceRoot.getWorkspace().newProjectDescription(cloneName);
	// copy project files
	project.copy(cloneDescription, true, m);
	final IProject clone = workspaceRoot.getProject(cloneName);
	// copy the project properties
	cloneDescription.setNatureIds(projectDescription.getNatureIds());
	cloneDescription.setReferencedProjects(projectDescription.getReferencedProjects());
	cloneDescription.setDynamicReferences(projectDescription.getDynamicReferences());
	cloneDescription.setBuildSpec(projectDescription.getBuildSpec());
	cloneDescription.setReferencedProjects(projectDescription.getReferencedProjects());
	clone.setDescription(cloneDescription, null);
	return clone;
}
 
Example 7
Source Project: JReFrameworker   Source File: JReFrameworker.java    License: MIT License 6 votes vote down vote up
private static IJavaProject createProject(String projectName, IPath projectPath, IProject project, IProgressMonitor monitor) throws CoreException {
	IProjectDescription projectDescription = project.getWorkspace().newProjectDescription(project.getName());
	URI location = getProjectLocation(projectName, projectPath);
	projectDescription.setLocationURI(location);
	
	// make this a JReFrameworker project
	projectDescription.setNatureIds(new String[] { JReFrameworkerNature.NATURE_ID, JavaCore.NATURE_ID });

	// build first with Java compiler then JReFramewoker bytecode operations
	BuildCommand javaBuildCommand = new BuildCommand();
	javaBuildCommand.setBuilderName(JavaCore.BUILDER_ID);
	BuildCommand jrefBuildCommand = new BuildCommand();
	jrefBuildCommand.setBuilderName(JReFrameworkerBuilder.BUILDER_ID);
	projectDescription.setBuildSpec(new ICommand[]{ javaBuildCommand, jrefBuildCommand});

	// create and open the Eclipse project
	project.create(projectDescription, null);
	IJavaProject jProject = JavaCore.create(project);
	project.open(new NullProgressMonitor());
	return jProject;
}
 
Example 8
/**
 * Add our {@code appengine-web.xml} builder that monitors for changes to the {@code <runtime>}
 * element.
 */
private static void addAppEngineWebBuilder(IProject project) {
  try {
    IProjectDescription projectDescription = project.getDescription();
    ICommand[] commands = projectDescription.getBuildSpec();
    for (int i = 0; i < commands.length; i++) {
      if (AppEngineWebBuilder.BUILDER_ID.equals(commands[i].getBuilderName())) {
        return;
      }
    }
    ICommand[] newCommands = new ICommand[commands.length + 1];
    // Add it after other builders.
    System.arraycopy(commands, 0, newCommands, 0, commands.length);
    // add builder to project
    ICommand command = projectDescription.newCommand();
    command.setBuilderName(AppEngineWebBuilder.BUILDER_ID);
    newCommands[commands.length] = command;
    projectDescription.setBuildSpec(newCommands);
    project.setDescription(projectDescription, null);
    logger.finer(project + ": added AppEngineWebBuilder");
  } catch (CoreException ex) {
    logger.log(Level.SEVERE, "Unable to add builder for " + project, ex);
  }
}
 
Example 9
Source Project: bonita-studio   Source File: ProjectAssert.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verifies that the actual IProject's description is equal to the given one.
 *
 * @param description the given description to compare the actual IProject's description to.
 * @return this assertion object.
 * @throws CoreException
 * @throws AssertionError - if the actual IProject's description is not equal to the given one.
 */
public ProjectAssert hasDescription(final IProjectDescription description) throws CoreException, AssertionError {
    // check that actual IProject we want to make assertions on is not null.
    isNotNull();

    // we overrides the default error message with a more explicit one
    final String errorMessage = format("\nExpected <%s> description to be:\n  <%s>\n but was:\n  <%s>", actual, description, actual.getDescription());

    // check
    if (!actual.getDescription().equals(description)) {
        throw new AssertionError(errorMessage);
    }

    // return the current assertion for method chaining
    return this;
}
 
Example 10
Source Project: xtext-eclipse   Source File: ProjectFactory.java    License: Eclipse Public License 2.0 6 votes vote down vote up
protected IProjectDescription createProjectDescription() {
	final IProjectDescription projectDescription = workspace.newProjectDescription(projectName);
	if (location != null && !Platform.getLocation().equals(location.removeLastSegments(1))) {
		projectDescription.setLocation(location);
	}

	if (referencedProjects != null && referencedProjects.size() != 0) {
		projectDescription
				.setReferencedProjects(referencedProjects.toArray(new IProject[referencedProjects.size()]));
	}
	if (projectNatures != null)
		projectDescription.setNatureIds(projectNatures.toArray(new String[projectNatures.size()]));
	if (builderIds != null)
		setBuilder(projectDescription, builderIds.toArray(new String[builderIds.size()]));
	return projectDescription;
}
 
Example 11
Source Project: JReFrameworker   Source File: JReFrameworkerNature.java    License: MIT 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(JReFrameworkerBuilder.BUILDER_ID)) {
			return;
		}
	}

	ICommand[] newCommands = new ICommand[commands.length + 1];
	System.arraycopy(commands, 0, newCommands, 0, commands.length);
	ICommand command = desc.newCommand();
	command.setBuilderName(JReFrameworkerBuilder.BUILDER_ID);
	newCommands[newCommands.length - 1] = command;
	desc.setBuildSpec(newCommands);
	project.setDescription(desc, null);
}
 
Example 12
Source Project: xtext-eclipse   Source File: IResourcesSetupUtil.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public static void removeNature(IProject project, String nature)
		throws CoreException {
	IProjectDescription description = project.getDescription();
	String[] natures = description.getNatureIds();

	for (int i = 0; i < natures.length; ++i) {
		if (nature.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;
		}
	}

}
 
Example 13
Source Project: cppcheclipse   Source File: Nature.java    License: Apache License 2.0 6 votes vote down vote up
public void configure() throws CoreException {
	// add builder to list of proect builders
	IProjectDescription desc = project.getDescription();
	ICommand[] commands = desc.getBuildSpec();
	for (int i = 0; i < commands.length; ++i) {
		if (commands[i].getBuilderName().equals(Builder.BUILDER_ID)) {
			return;
		}
	}
	ICommand[] newCommands = new ICommand[commands.length + 1];
	System.arraycopy(commands, 0, newCommands, 0, commands.length);
	ICommand command = desc.newCommand();
	command.setBuilderName(Builder.BUILDER_ID);
	newCommands[newCommands.length - 1] = command;
	desc.setBuildSpec(newCommands);
	project.setDescription(desc, null);
}
 
Example 14
Source Project: birt   Source File: IDEOpenSampleReportAction.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private void create( IProjectDescription description,
		IProject projectHandle, IProgressMonitor monitor )
		throws CoreException, OperationCanceledException
{
	try
	{
		monitor.beginTask( "", 2000 );//$NON-NLS-1$
		projectHandle.create( description, new SubProgressMonitor( monitor,
				1000 ) );
		if ( monitor.isCanceled( ) )
			throw new OperationCanceledException( );
		projectHandle.open( new SubProgressMonitor( monitor, 1000 ) );

	}
	finally
	{
		monitor.done( );
	}
}
 
Example 15
Source Project: xtext-eclipse   Source File: IResourcesSetupUtil.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public static void setReference(final IProject from, final IProject to)
		throws CoreException, InvocationTargetException,
		InterruptedException {
	new WorkspaceModifyOperation() {

		@Override
		protected void execute(IProgressMonitor monitor)
				throws CoreException, InvocationTargetException,
				InterruptedException {
			IProjectDescription projectDescription = from.getDescription();
			IProject[] projects = projectDescription
					.getReferencedProjects();
			IProject[] newProjects = new IProject[projects.length + 1];
			System.arraycopy(projects, 0, newProjects, 0, projects.length);
			newProjects[projects.length] = to;
			projectDescription.setReferencedProjects(newProjects);
			from.setDescription(projectDescription, monitor());
		}
	}.run(monitor());
}
 
Example 16
Source Project: sarl   Source File: SARLProjectConfigurator.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void unconfigure(IProject project, IProgressMonitor monitor) throws CoreException {
	try {
		final SubMonitor mon = SubMonitor.convert(monitor, 4);
		final IProjectDescription description = project.getDescription();
		final List<String> natures = new LinkedList<>(Arrays.asList(description.getNatureIds()));
		natures.remove(SARLEclipseConfig.XTEXT_NATURE_ID);
		natures.remove(SARLEclipseConfig.NATURE_ID);
		final String[] newNatures = natures.toArray(new String[natures.size()]);
		mon.worked(1);
		final IStatus status = ResourcesPlugin.getWorkspace().validateNatureSet(newNatures);
		mon.worked(1);
		if (status.getCode() == IStatus.OK) {
			description.setNatureIds(newNatures);
			project.setDescription(description, mon.newChild(1));
			safeRefresh(project, mon.newChild(1));
		} else {
			throw new CoreException(status);
		}
	} finally {
		monitor.done();
	}
}
 
Example 17
Source Project: APICloud-Studio   Source File: ResourceUtil.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Reurns a list of all the natures that belong to Aptana.
 * 
 * @param description
 * @return
 */
public static String[] getAptanaNatures(IProjectDescription description)
{
	String[] natures = description.getNatureIds();
	List<String> newNatures = new ArrayList<String>();
	// Add Aptana natures to list
	for (String nature : natures)
	{
		if (isAptanaNature(nature))
		{
			newNatures.add(nature);
		}
	}

	return newNatures.toArray(new String[newNatures.size()]);
}
 
Example 18
Source Project: JReFrameworker   Source File: JReFrameworkerProject.java    License: MIT License 6 votes vote down vote up
public void enableJavaBuilder() throws CoreException {
	IProjectDescription desc = project.getDescription();
	ICommand[] commands = desc.getBuildSpec();
	// if the command already exists, don't add it again
	for (int i = 0; i < commands.length; ++i) {
		if (commands[i].getBuilderName().equals(JavaCore.BUILDER_ID)) {
			return;
		}
	}
	ICommand[] newCommands = new ICommand[commands.length + 1];
	System.arraycopy(commands, 0, newCommands, 0, commands.length);
	ICommand command = desc.newCommand();
	command.setBuilderName(JavaCore.BUILDER_ID);
	newCommands[newCommands.length - 1] = command;
	
	if(!command1PreceedsCommand2(JavaCore.BUILDER_ID, JReFrameworkerBuilder.BUILDER_ID, newCommands)){
		swapBuildCommands(JavaCore.BUILDER_ID, JReFrameworkerBuilder.BUILDER_ID, newCommands);
	}
	
	desc.setBuildSpec(newCommands);
	project.setDescription(desc, null);
}
 
Example 19
Source Project: RADL   Source File: RadlCreatorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void init() throws CoreException {
  IProjectDescription description = mock(IProjectDescription.class);
  when(description.getBuildSpec()).thenReturn(new ICommand[0]);
  when(description.newCommand()).thenReturn(mock(ICommand.class));
  when(description.getNatureIds()).thenReturn(natureIds.toArray(new String[natureIds.size()]));
  doAnswer(new Answer<Void>() {
    @Override
    public Void answer(InvocationOnMock invocation) throws Throwable {
      natureIds.clear();
      natureIds.addAll(Arrays.asList((String[])invocation.getArguments()[0]));
      return null;
    }
  }).when(description).setNatureIds(any(String[].class));
  when(project.getDescription()).thenReturn(description);
  when(folder.getProject()).thenReturn(project);
  when(folder.exists()).thenReturn(true);
  when(folder.getFile(anyString())).thenReturn(file);
  when(root.getFolder(new Path(folderName))).thenReturn(folder);
}
 
Example 20
Source Project: hybris-commerce-eclipse-plugin   Source File: Importer.java    License: Apache License 2.0 6 votes vote down vote up
private void addHybrisNature(IProject project, IProgressMonitor monitor) throws CoreException {
	IProjectDescription description = project.getDescription();
	String[] natures = description.getNatureIds();

	for (int i = 0; i < natures.length; ++i) {
		if (HYBRIS_NATURE_ID.equals(natures[i])) {
			return;
		}
	}

	// Add the nature
	String[] newNatures = new String[natures.length + 1];
	System.arraycopy(natures, 0, newNatures, 0, natures.length);
	newNatures[natures.length] = HYBRIS_NATURE_ID;
	description.setNatureIds(newNatures);
	project.setDescription(description, monitor);
}
 
Example 21
public static void addJavaNature(IProject project, IProgressMonitor monitor) throws CoreException {
	if (monitor != null && monitor.isCanceled()) {
		throw new OperationCanceledException();
	}
	if (!project.hasNature(JavaCore.NATURE_ID)) {
		IProjectDescription description = project.getDescription();
		String[] prevNatures= description.getNatureIds();
		String[] newNatures= new String[prevNatures.length + 1];
		System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
		newNatures[prevNatures.length]= JavaCore.NATURE_ID;
		description.setNatureIds(newNatures);
		project.setDescription(description, monitor);
	} else {
		if (monitor != null) {
			monitor.worked(1);
		}
	}
}
 
Example 22
/**
 * Creates a new project in the workbench from an existing one
 * 
 * @param monitor
 * @throws CoreException
 */

void createExistingProject(IProgressMonitor monitor)
        throws CoreException {
    String projectName = project.getName();
    IProjectDescription description;

    try {
        monitor.beginTask("Creating " + projectName, 2 * 1000);

        description = ResourcesPlugin.getWorkspace()
                .loadProjectDescription(
                        new Path(directory + File.separatorChar
                                + ".project")); //$NON-NLS-1$

        description.setName(projectName);
        project.create(description, new SubProgressMonitor(monitor,
                1000));
        project.open(new SubProgressMonitor(monitor, 1000));
    } finally {
        monitor.done();
    }
}
 
Example 23
@Test
public void testPreexistingIProjectDifferentName() throws Exception {
	File from = new File(getSourceProjectDirectory(), "maven/salut");
	Path projectDir = Files.createTempDirectory("testImportDifferentName");

	IWorkspaceRoot wsRoot = WorkspaceHelper.getWorkspaceRoot();
	IWorkspace workspace = wsRoot.getWorkspace();
	String projectName = projectDir.getFileName().toString();
	IProject salut = wsRoot.getProject("salut");
	salut.delete(true, monitor);
	IProjectDescription description = workspace.newProjectDescription(projectName);
	description.setLocation(new org.eclipse.core.runtime.Path(projectDir.toFile().getAbsolutePath()));

	IProject project = wsRoot.getProject(projectName);
	project.create(description, monitor);


	assertTrue(WorkspaceHelper.getAllProjects().contains(project));

	FileUtils.copyDirectory(from, projectDir.toFile());

	assertTrue(project.exists());
	Job updateJob = projectsManager.updateWorkspaceFolders(Collections.singleton(new org.eclipse.core.runtime.Path(projectDir.toString())), Collections.emptySet());
	updateJob.join(20000, monitor);
	assertTrue("Failed to import preexistingProjectTest:\n" + updateJob.getResult().getException(), updateJob.getResult().isOK());
}
 
Example 24
Source Project: xds-ide   Source File: NatureUtils.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public static void removeNature(IProject project, String nature) {
	try {
		IProjectDescription description = project.getDescription();
		String[] currentNatures = description.getNatureIds();

		int index = 0;
		for (int i = 0; i < currentNatures.length; i++) {
			if (nature.equals(currentNatures[i])) {
				index = i;
				break;
			}
		}

		if (index != -1) {
			String[] newNatures = new String[currentNatures.length - 1];
			System.arraycopy(currentNatures, 0, newNatures, 0, index);
			System.arraycopy(currentNatures, index + 1, newNatures, index,
					newNatures.length - index);
			description.setNatureIds(newNatures);
			project.setDescription(description, null);
		}
	} catch (CoreException e) {
		LogHelper.logError(e);
	}
}
 
Example 25
/**
 * Removes the given builder from the build spec for the given project.
 */
protected void removeFromBuildSpec(String builderID) throws CoreException {
    MarkerUtil.removeMarkers(getProject());
    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);
            getProject().setDescription(description, null);
            return;
        }
    }
}
 
Example 26
/**
 * {@inheritDoc}
 */
@Override
public void deconfigure() throws CoreException {

  //
  // Remove the builder from the project.
  //
  IProjectDescription description = mProject.getDescription();
  ICommand[] commands = description.getBuildSpec();
  List<ICommand> newCommandsVec = new ArrayList<>();
  for (int i = 0; i < commands.length; ++i) {
    if (commands[i].getBuilderName().equals(CheckstyleBuilder.BUILDER_ID)) {
      continue;
    } else {
      newCommandsVec.add(commands[i]);
    }
  }

  ICommand[] newCommands = newCommandsVec.toArray(new ICommand[newCommandsVec.size()]);
  description.setBuildSpec(newCommands);

  ensureProjectFileWritable();

  mProject.setDescription(description, new NullProgressMonitor());

  // remove checkstyle markers from the project
  getProject().deleteMarkers(CheckstyleMarker.MARKER_ID, true, IResource.DEPTH_INFINITE);

}
 
Example 27
Source Project: RADL   Source File: RadlNature.java    License: Apache License 2.0 5 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 (RadlBuilder.BUILDER_ID.equals(commands[i].getBuilderName())) {
      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);
      getProject().setDescription(description, null);
      return;
    }
  }
}
 
Example 28
/**
 * Find the specific FindBugs command amongst the build spec of a given
 * description
 */
private ICommand getFindBugsCommand(IProjectDescription description) {
    ICommand[] commands = description.getBuildSpec();
    for (int i = 0; i < commands.length; ++i) {
        if (FindbugsPlugin.BUILDER_ID.equals(commands[i].getBuilderName())) {
            return commands[i];
        }
    }
    return null;
}
 
Example 29
/***/
protected PlatformResourceURI createTempProject(N4JSProjectName projectName) throws CoreException {
	IProjectDescription description = workspace.getWorkspace()
			.newProjectDescription(projectName.toEclipseProjectName().getRawName());
	// deliberately avoid the build command
	description.setNatureIds(new String[] { XtextProjectHelper.NATURE_ID });
	IProject newProject = workspace.getProject(projectName.toEclipseProjectName().getRawName());
	newProject.create(null);
	newProject.open(null);
	newProject.setDescription(description, null);
	return new PlatformResourceURI(newProject);
}
 
Example 30
Source Project: n4js   Source File: N4JSTasksExampleWizard.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private static void importProject(IWorkspace workspace, File rootFolder, IProgressMonitor progressMonitor)
		throws CoreException {
	IPath path = new org.eclipse.core.runtime.Path(new File(rootFolder, ".project").getAbsolutePath());
	IProjectDescription desc = workspace.loadProjectDescription(path);
	IProject project = workspace.getRoot().getProject(desc.getName());
	project.create(desc, progressMonitor);
	project.open(progressMonitor);
}