Re: project conversion questions
Tomas Zezula <[email protected]> Thu, 31 Jul 2003 07:57:02 +0200
| Newsgroups | gmane.comp.java.netbeans.modules.projects.devel |
|---|---|
| Organization | Sun Microsystems |
| Message-ID | <[email protected]> |
Hi Peter,
if the wizard is a TemplateWizard and the template exists on the
ProjectFilesystem, you can try this:
Register the TemplateWizard using the methodvalue.
...
<attr name="instaceCreate" methodvalue="mypackage.MyClass.create"
...
the create method should have the following signature:
public static MyClass create (FileObject fo) {
Project p = Project.find (fo);
return new MyClass (p);
}
In addition to this some Wizard are putting the Project into
the "project" property (use TemplateWizard.getProperty()).
Tomas
On Wed, 2003-07-30 at 18:30, Peter Wisnovsky wrote:
> > Instead of DataObject.find() just use
> > theProjectInstance.getProjectMember(theFile) to get a ProjectMember
> > (file's representant within the project).
>
> Hmm...so I tried this conversion and did it in a wizard, where I don't
> have a project. (I notice there is no getTargetProject in the
> TemplateWizard class...should there be?). When I try:
>
>
> protected ClassElementDescriptor createClassElement(String name, ClassBuilder worker)
> throws IOException, DataObjectNotFoundException, SourceException
> {
> DataFolder folder = wiz.getTargetFolder();
> FileObject packageObject = folder.getPrimaryFile();
> FileObject fileObject = packageObject.createData(name, "java");
> ProjectMember javaObject = ProjectMember.find(fileObject);
> if (javaObject == null)
> {
> throw new RuntimeException("Could not find newly created object");
> }
>
> I get
>
> java.lang.RuntimeException: Could not find newly created object
> at com.sun.s1s.jpe.module.resources.MetaClassWizardIterator.createClassElement(MetaClassWizardIterator.java:78)
> at com.sun.s1s.jpe.module.resources.ServiceWizardIterator.instantiate(ServiceWizardIterator.java:164)
> at org.openide.loaders.TemplateWizard.handleInstantiate(TemplateWizard.java:513)
> at org.openide.loaders.TemplateWizard.instantiateImpl(TemplateWizard.java:438)
> at org.openide.loaders.TemplateWizard.instantiate(TemplateWizard.java:354)
> at org.netbeans.modules.projects.ide.actions.NewFileAction.actionPerformed(NewFileAction.java:110)
> at org.netbeans.core.ModuleActions$1.run(ModuleActions.java:97)
> at org.openide.util.Task.run(Task.java:136)
> at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:330)
> [catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:677)
>
> Any suggestions?
>
> Thanks again for all the help I've been getting working through these
> issues...
>
> Peter
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>