|
|
| Re: Programmatically creating a project ? [message #109439 is a reply to message #108773] |
Mon, 11 August 2003 05:00   |
Eclipse User |
|
|
|
Originally posted by: mh.nixspam.com
"Thorsten Prumbs" <tprumbs@atsistemas.com> wrote in message
news:bh007a$89g$1@eclipse.org...
> To get started, have a look at the eclipse source.
> E.g. BasicNewProjectResourceWizard (eclipse.ui) or
> NewProjectCreationWizard (jdt.ui)
>
> The code to create a new project will be s.th. like this:
> ...
> IWorkspace w=ResourcesPlugin.getWorkspace();
> IProject projHandle = w.getRoot().getProject("yourProjectName");
> IProjectDescription desc=w.newProjectDescription(projHandle.getName());
> desc.setLocation(yourPath);
> projHandle.create(desc, monitor);
> projHandle.open(monitor);
> ...
>
> projHandle is your new Project. To add a Nature you'll have s.th. like
this:
> ...
> IProjectDescription desc = project.getDescription();
> String[] prevNatures= desc.getNatureIds();
> String[] newNatures= new String[prevNatures.length + 1];
> System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
> newNatures[prevNatures.length]= YOUR_NATURE_ID;
> desc.setNatureIds(newNatures);
> project.setDescription(desc, monitor);
> ...
>
> The JDT wizards are a bit complex but after a while you'll find the
example
> what you look for. Most of it is internal so shouldn't be extended. But
the
> ResourceWizards are open for reusage.
Thanks, that looks already good, but I get with the following lines at the
last in this snippet an "Invalid project description." error.
---snip---
IPath path = new Path("C:/temp");
IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IProject newProjectHandle = workspace.getRoot().getProject("ABC123");
IProjectDescription description =
workspace.newProjectDescription(newProjectHandle.getName());
description.setLocation(path);
newProjectHandle.create(description, monitor);
---snap---
Any ideas?
Mario
|
|
|
| Re: Programmatically creating a project ? [message #109710 is a reply to message #109439] |
Mon, 11 August 2003 15:03  |
Eclipse User |
|
|
|
Originally posted by: John_Arthorne.oti.com_
That exception will contain a MultiStatus object, and its children will
tell you exactly what you did wrong. An easy way to see all the details
is to log the status object (YourPlugin.getLog().log(IStatus)), and then
see all the details in the log file.
--
Mario Herger wrote:
>
> Thanks, that looks already good, but I get with the following lines at the
> last in this snippet an "Invalid project description." error.
>
> ---snip---
> IPath path = new Path("C:/temp");
> IWorkspace workspace = ResourcesPlugin.getWorkspace();
> final IProject newProjectHandle = workspace.getRoot().getProject("ABC123");
> IProjectDescription description =
> workspace.newProjectDescription(newProjectHandle.getName());
> description.setLocation(path);
> newProjectHandle.create(description, monitor);
>
> ---snap---
>
> Any ideas?
>
> Mario
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.06071 seconds