Re: project conversion questions
Tomas Zezula <[email protected]> Thu, 31 Jul 2003 08:08:36 +0200
| Newsgroups | gmane.comp.java.netbeans.modules.projects.devel |
|---|---|
| Organization | Sun Microsystems |
| Message-ID | <[email protected]> |
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");
> }
The Project.find () can be used only with FilObject that are on the
ProjectFilesystem (e.g. the template, the instance file)
If the FileObject does not exist on the ProjectFS, you have to use
Project.findAll(). But this method should be used only if you don't have
any other chance to get the Project. The problem with this method is
that it returns an array of Projects to which the FileObject belongs.
If I were you, I would prefer the way I have described in the previous
email.
Tomas
>
> 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]
>