Java Project creation [message #215792] |
Wed, 28 September 2005 07:07  |
Eclipse User |
|
|
|
Originally posted by: mom.mom.gmx.net
Hi,
im writing a Plugin for a Java type Project. This means I need a Java
Project in the Workspace, but I also want to setup some things while
creation.
I found the JavaProjectWizard, but it is too much, I only need the First
page (JavaProjectWizardFirstPage). Is there a way to hide the second Page ?
Or better, how can I create a Java Project by myself ? Mean I create a
Wizard with the things really needed, and after the user clicked finish
I can call JDT to create the Project. I found JavaCore.create(IProject),
but I'm not sure from where to get the IProject Parameter?
thanks for help
regards Rainer
|
|
|
Re: Java Project creation [message #215854 is a reply to message #215792] |
Thu, 29 September 2005 05:39   |
Eclipse User |
|
|
|
You can write your own wizard and add JavaProjectWizardFirstPage to
create the java project.
For creating project using code:
IProject myProject =
ResourcesPlugin.getWorkspace().getRoot().getProject("Project1 ");
myProject.create(null);
myProject.open(null);
IProjectDescription description = project.getDescription();
String[] natures = description.getNatureIds();
String[] newNatures = new String[natures.length+1];
System.arraycopy(natures, 0, newNatures, 0, natures.length);
newNatures[natures.length] = JavaCore.NATURE_ID;
description.setNatureIds(newNatures);
project.setDescription(description, null);
Rainer Weinhold wrote:
> Hi,
>
> im writing a Plugin for a Java type Project. This means I need a Java
> Project in the Workspace, but I also want to setup some things while
> creation.
>
> I found the JavaProjectWizard, but it is too much, I only need the First
> page (JavaProjectWizardFirstPage). Is there a way to hide the second Page ?
> Or better, how can I create a Java Project by myself ? Mean I create a
> Wizard with the things really needed, and after the user clicked finish
> I can call JDT to create the Project. I found JavaCore.create(IProject),
> but I'm not sure from where to get the IProject Parameter?
>
> thanks for help
>
> regards Rainer
|
|
|
Re: Java Project creation [message #215882 is a reply to message #215854] |
Thu, 29 September 2005 10:09  |
Eclipse User |
|
|
|
Originally posted by: mom.mom.gmx.net
I testet your code, it works fine.
Except on little thing. (I guess the variable project was meant to be
called myProject.)
When running, it created the Project, and it creates a "bin" directory
within. But in this "bin" Directory there is a second .project file. It
happens in the myProject.setDescription(.... line.
This ist not very nice, but I can live with it. So I added a litte more
code :
IJavaProject javaProject=JavaCore.create(myProject);
JavaProject jp=(JavaProject)javaProject;
String str="/"+myProject.getName()+"/test";
jp.setOutputLocation( new Path(str),null);
The code works, it sets the output location in the Project, as long as I
didn't say ist schould be: ...+"/bin", then nothing happens and the
Output directory stays in the Project Folder.
Rainer
eddie schrieb:
> You can write your own wizard and add JavaProjectWizardFirstPage to
> create the java project.
>
> For creating project using code:
>
> IProject myProject =
> ResourcesPlugin.getWorkspace().getRoot().getProject("Project1 ");
> myProject.create(null);
> myProject.open(null);
> IProjectDescription description = project.getDescription();
> String[] natures = description.getNatureIds();
> String[] newNatures = new String[natures.length+1];
> System.arraycopy(natures, 0, newNatures, 0, natures.length);
> newNatures[natures.length] = JavaCore.NATURE_ID;
> description.setNatureIds(newNatures);
> project.setDescription(description, null);
>
>
>
>
> Rainer Weinhold wrote:
>
>> Hi,
>>
>> im writing a Plugin for a Java type Project. This means I need a Java
>> Project in the Workspace, but I also want to setup some things while
>> creation.
>>
>> I found the JavaProjectWizard, but it is too much, I only need the First
>> page (JavaProjectWizardFirstPage). Is there a way to hide the second
>> Page ?
>> Or better, how can I create a Java Project by myself ? Mean I create a
>> Wizard with the things really needed, and after the user clicked finish
>> I can call JDT to create the Project. I found JavaCore.create(IProject),
>> but I'm not sure from where to get the IProject Parameter?
>>
>> thanks for help
>>
>> regards Rainer
|
|
|
Powered by
FUDForum. Page generated in 0.02809 seconds