To see a new file template in the "New File Wizard" when you don't want to use 
templates in your application, you have to add 'requireProject=false' to the 
@TemplateRegistration.

https://bits.netbeans.org/12.6/javadoc/org-netbeans-api-templates/org/netbeans/api/templates/TemplateRegistration.html

I added requireProject=false to mine, and it now shows up in the New File 
Wizard.

Thanks to everyone!
Peter

________________________________
From: Peter Blemel <pble...@hotmail.com>
Sent: Saturday, January 22, 2022 8:02 PM
To: Michael Bien <mbie...@gmail.com>; dev@netbeans.apache.org 
<dev@netbeans.apache.org>
Subject: Re: How to add 'File -> New' and 'File -> Open' to a NB 12.6 platform 
application?

Thanks Michael,

Just to be clear, I can open my file type.  I can't create a new one using the 
wizard. Here's what I've just done at your suggestion:

  1.  Create a new platform application (Java with Ant -> NetBeans Platform 
Application)
  2.  Create a new module "TestModule", code name base "testapp" (Generate OSGi 
Bundle is not checked)
  3.  Create foo file type (Module Development -> File Type, mime type 
application/foo, extension foo, Class Name Prefix Foo, "Use MultiView" checked 
by default.)
  4.  Add New Window (class name prefix Foo)
  5.  TestApp -> Properties -> Libraries -> ide cluster -> check "User 
Utilities", "Project API", "Project UI" (this requires "Resolve"ing 
dependencies"
  6.  "User Utilities" is for the File -> Open menu.  The others are for the 
"File -> New" menu.
  7.  Run my stand-alone test app (more specifically, I use "Debug" out of 
habit)
  8.  File -> New
  9.  At this point, the only Category is "Other" and "File Type" is "Folder".  
My 'foo' type is not a choice.

The File Template Tutorial does have additional steps; Namely, adding a couple 
of files and updating the package-info.java, so I do that just in case it's 
necessary:

  1.  New -> Other -> HTML-> Description.html
  2.  Copy my icon into the testapp package
  3.  Change package-info.java

Was :
@TemplateRegistration(folder = "Other", content = "FooTemplate.foo")
package testapp;
import org.netbeans.api.templates.TemplateRegistration;

Now :
@TemplateRegistration(
        folder = "Other",
        iconBase="testapp/knowledgebase.png",
        displayName = "#HTMLtemplate_displayName",
        content = "FooTemplate.foo",
        description = "Description.html")
@Messages(value = "HTMLtemplate_displayName=Empty Foo file")

package testapp;

import org.netbeans.api.templates.TemplateRegistration;
import org.openide.util.NbBundle.Messages;

  1.  Run
  2.  File -> New
  3.  At this point, the only Category is still "Other" and "File Type" is 
"Folder".  My 'foo' type is not a choice.

Note that the png requires the package name, or the IDE complains.  The content 
and description do not (adding the package name makes the IDE complain).

I realize that at this point I am not using a Project in my application. I will 
eventually, but I would first like to create an application that can use the 
File->New box to create and edit a file, then work with projects later.

Thanks,
Peter

________________________________
From: Michael Bien <mbie...@gmail.com>
Sent: Saturday, January 22, 2022 7:11 PM
To: dev@netbeans.apache.org <dev@netbeans.apache.org>; Peter Blemel 
<pble...@hotmail.com>
Subject: Re: How to add 'File -> New' and 'File -> Open' to a NB 12.6 platform 
application?

Hi Peter,

could you try this again without following any tutorial? :)

I just tested the following:

- created new ant based standalone module just like you did

- added a "foo" file type using the new -> File Type wizzard

- added a window using the new -> Window wizzard

- ran the project (on JDK 17 just like in your setup) and it worked


.foo files were now recognized and i could open the (empty) window via
window -> window_name

(haven't typed a single line of code for that)


your log complains about not being able to access some modules (java
module system, not nb module system). This typically happens when the
JMS module has not been added via --add-opens on JVM start. But this is
not something you should have to do since its already in netbeans.conf
of the platform.

for example when i run the project i see something like this:
Diagnostic information
Input arguments:
     -Djdk.home=/home/mbien/dev/java/jdk-17.0.2.8.1-corretto
     -Dnetbeans.default_userdir_root=/home/mbien/.netbeans
... more flags
     --add-opens=java.base/java.net=ALL-UNNAMED
     --add-opens=java.base/java.lang.ref=ALL-UNNAMED
... more add-opens


I don't see this in your log.


-michael



Reply via email to