use of org.eclipse.core.resources.IProjectDescription in project xtext-xtend by eclipse.
the class EclipseFileSystemTest method testGetURIForImportedProject.
@Test
public void testGetURIForImportedProject() {
try {
final IWorkspace ws = ResourcesPlugin.getWorkspace();
final IWorkspaceRoot root = ws.getRoot();
final IProjectDescription description = ws.newProjectDescription("bar");
description.setLocation(root.getLocation().append("foo/bar"));
final IProject project = root.getProject("bar");
project.create(description, null);
project.open(null);
final Path file = new Path("/bar/Foo.text");
Assert.assertFalse(this.fs.exists(file));
Assert.assertNull(this.fs.toURI(file));
try {
this.fs.setContents(file, "Hello Foo");
Assert.fail();
} catch (final Throwable _t) {
if (_t instanceof IllegalArgumentException) {
} else {
throw Exceptions.sneakyThrow(_t);
}
}
Assert.assertFalse(this.fs.exists(file));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.core.resources.IProjectDescription in project linuxtools by eclipse.
the class RemoteProxyNatureMapping method getSchemeFromNature.
public String getSchemeFromNature(IProject project) throws CoreException {
IProjectDescription description = project.getDescription();
String[] natures = description.getNatureIds();
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(ProfileLaunchPlugin.PLUGIN_ID, EXTENSION_POINT_ID);
IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
for (int i = 0; i < infos.length; i++) {
IConfigurationElement configurationElement = infos[i];
if (configurationElement.getName().equals(MANAGER_NAME)) {
for (int j = 0; j < natures.length; j++) {
if (configurationElement.getAttribute(NATURE_ID).equals(natures[j])) {
return configurationElement.getAttribute(SCHEME_ID);
}
}
}
}
return null;
}
use of org.eclipse.core.resources.IProjectDescription in project linuxtools by eclipse.
the class CProjectHelper method addNatureToProject.
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);
}
use of org.eclipse.core.resources.IProjectDescription in project linuxtools by eclipse.
the class CProjectHelper method addNatureToProject.
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);
}
use of org.eclipse.core.resources.IProjectDescription in project linuxtools by eclipse.
the class RPMProjectCreator method create.
/**
* Creates a project with the given name in the given location.
*
* @param projectName
* The name of the project.
* @param projectPath
* The parent location of the project.
* @param monitor
* Progress monitor to report back status.
* @return The newly created project.
* @throws CoreException If the location is wrong.
*/
public IProject create(String projectName, IPath projectPath, IProgressMonitor monitor) throws CoreException {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(projectName);
IProjectDescription description = ResourcesPlugin.getWorkspace().newProjectDescription(project.getName());
String parsedIPathString = null;
if (!Platform.getLocation().equals(projectPath)) {
// $NON-NLS-1$ //$NON-NLS-2$
parsedIPathString = projectPath.toString().replaceFirst(":/", "://");
try {
description.setLocationURI(new URI(parsedIPathString));
} catch (URISyntaxException e) {
throw new CoreException(new Status(IStatus.ERROR, IRPMConstants.RPM_CORE_ID, e.getMessage(), e));
}
}
description.setNatureIds(new String[] { IRPMConstants.RPM_NATURE_ID });
project.create(description, monitor);
monitor.worked(10);
project.open(monitor);
new RPMProject(project, layout);
return project;
}
Aggregations