[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [cdt-dev] Programatically opening a project
|
Yep, i've tried it, but it didnt work. Luckily, i've already discovered the reason. That workspace had a project with the same name. I've just changed the project name in the .project file and now it works just fine. Thanks for help!
Best Regards.
W dniu 26 lipca 2011 12:19 użytkownik Elmenthaler, Jens
<jens.elmenthaler@xxxxxxxxxx> napisał:
Have you tried the code? It imports code from everywhere in the file system, just give it a path to a directory containing a .project.
Jens.
Hello!
Unfortunately it's not what i was looking for. It seems your code only imports a project that belongs to the workspace's filesystem. The eclipse API documentation for loadProjectDescription() reads -
This object is useful for discovering the correct name for a project before importing it into the workspace. And for getProject() -
Returns a handle to the project resource with the given name which is a child of this root. So, what do I have to do to import a project, that's not a child of the current workspace's root? "Import Existing Projects
into Workspace" does exactly something like this.
W dniu 25 lipca 2011 17:04 użytkownik Elmenthaler, Jens <jens.elmenthaler@xxxxxxxxxx> napisał:
This is what I use:
/**
* Import the Eclipse project at the given path.
*
* @param path
* The root directory containing the .project file.
* @param flags
* {@link IResource#BACKGROUND_REFRESH} or 0.
* @param monitor
* @return The imported project.
*/
public static IProject importProjectAt(String path, int flags,
IProgressMonitor monitor) {
try {
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
IPath projectPath = new Path(path).append(".project");
IProjectDescription description = workspace
.loadProjectDescription(projectPath);
IProject project = workspace.getRoot().getProject(
description.getName());
if (!project.exists()) {
project.create(description,
new SubProgressMonitor(monitor, 30));
} else {
monitor.worked(30);
}
project.open(flags, new SubProgressMonitor(monitor,
70));
return project;
} catch (CoreException e) {
log(e);
}
return null;
}
Jens.
Well, I'll change my question then. Is it possible to import a project to the current workspace programmatically,
just like it is done by the "Import Existing Projects into Workspace" GUI option? I believe eclipse is just looking for .project files in the file tree we choose. I found a piece of code that should do it here -
http://blog.yahor.net/2009/05/import-existing-project-into-eclipse.html. Unfortunately it seems there is something more to it then this.
Best Regards,
Radosław Fijołek
W dniu 20 lipca 2011 14:52 użytkownik Andrew Gvozdev <angvoz.dev@xxxxxxxxx>
napisał:
2011/7/20 Andrew Gvozdev <angvoz.dev@xxxxxxxxx>
Hi Radosław,
2011/7/20 Radosław Fijołek <lelokrates@xxxxxxxxx>
Hello!
Is it possible to programatically open/load a project using CDT? Unfortunately the following method:
String name = ...;
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
does not satisfy me, as I am not allowed to load the eclipse platform. I'd rather run my app from command line.
It is called "platform" for a reason. You cannot use CDT without eclipse platform including opening projects.
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev