org.eclipse.core.internal.resources.ProjectDescription Java Examples

The following examples show how to use org.eclipse.core.internal.resources.ProjectDescription. 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 check out the related API usage on the sidebar.
Example #1
Source File: ExternalProject.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public ResourceInfo getResourceInfo(boolean phantom, boolean mutable) {
	ProjectDescription description = new ProjectDescription();
	description.setName(getName());
	description.setNatureIds(from(natureIds).toArray(String.class));
	ICommand[] buildSpecs = new ICommand[builderIds.size()];
	int i = 0;
	for (String builderId : builderIds) {
		ICommand command = description.newCommand();
		command.setBuilderName(builderId);
		buildSpecs[i++] = command;
	}
	description.setBuildSpec(buildSpecs);

	ProjectInfo info = new ProjectInfo();
	info.setModificationStamp(file.lastModified());
	info.setDescription(description);

	return info;
}
 
Example #2
Source File: AddModuleHandlerTest.java    From tlaplus with MIT License 5 votes vote down vote up
public void testCreateModuleStoreRelativePath() throws IOException, CoreException {
	// Need a per invocation temp directory to avoid writing to the same
	// .project file over and over again.
	final File tempDirectory = createTempDirectory();

	// Create...
	final File specFile = new File(tempDirectory + File.separator + "TestSpecName.tla");
	specFile.createNewFile();
	final Spec spec = Spec.createNewSpec("TestSpecName", specFile.getAbsolutePath(), false,
			new NullProgressMonitor());

	final AddModuleHandler addModuleHandler = new AddModuleHandler();
	final File moduleFileRaw = new File(tempDirectory + File.separator + "TestModuleName.tla");
	moduleFileRaw.createNewFile();
	final IFile moduleFile = addModuleHandler.createModuleFile(spec, "TestModuleName",
			new Path(moduleFileRaw.getAbsolutePath()));

	// ...check
	assertNotNull(moduleFile);
	assertTrue(moduleFile.isAccessible());
	assertTrue(moduleFile.isLinked());

	// could use non-internal alternative
	// project.getWorkspace().loadProjectDescription(path) instead, but then
	// need to known path to .project file
	assertTrue(spec.getProject() instanceof Project);
	final Project project = (Project) spec.getProject();
	final ProjectDescription description = project.internalGetDescription();
	final ProjectDescription pd = (ProjectDescription) description;
	final HashMap<IPath, LinkDescription> links = pd.getLinks();
	assertEquals(2, links.size()); // spec + module
	for (LinkDescription linkDescription : links.values()) {
		final URI uri = linkDescription.getLocationURI();
		assertTrue(uri.toASCIIString().startsWith(ResourceHelper.PARENT_ONE_PROJECT_LOC));
	}
}
 
Example #3
Source File: ProjectDescriptionBuilder.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ProjectDescription build() {
    projectDescription.setNatureIds(natureIds.stream().distinct().toArray(String[]::new));
    final Map<String, ICommand> builderCommmands = new HashMap<>();
    for (final String builderId : builderIds) {
        final ICommand command = projectDescription.newCommand();
        command.setBuilderName(builderId);
        builderCommmands.put(builderId, command);
    }
    projectDescription.setBuildSpec(builderCommmands.values().toArray(new ICommand[builderCommmands.values().size()]));
    return projectDescription;
}
 
Example #4
Source File: ProjectDescriptionBuilder.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
public ProjectDescriptionBuilder() {
    projectDescription = new ProjectDescription();
}