NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Generic New Wizard

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users
View previous topic :: View next topic  
Author Message
Florian Brunner
Posted via mailing list.





PostPosted: Thu Oct 23, 2008 9:41 am    Post subject: Generic New Wizard Reply with quote

Hi,

in the Wizard-Wizard, we can specify to register a new file type. We can
specify the number of panels, the category etc.
When we finish, the classes get created and with it an HTML-file
describing the new wizard. Everything is configured in the layer-file etc..
If we then open the "New File"-Wizard, we can see our new file type
under the specified category. The description gets displayed at the
bottom of the wizard. On the left side we see 2 Steps: "Choose File
Type" and "...". As soon we have selected a wizard and pressed next,
that wizard steps gets display, too, incremented by 1. If we go back to
the first panel, we see again "Choose File Type" and "...".

Unfortunatly everything seems to be very IDE specific: in the end one or
more files get created/ modified in the project, selected in the first
panel.

But I need (and probably others, too) to create some new business
objects. These business objects do not map to files but will be stored
in a DB or sent to an EJB or WebService. The "Projects"-concept does
often not exist and therefore no project-selection component should be
presented to the user. But most of the other requirements are
implemented by the existing "New File"-dialog:

- an extension point to register custom wizards in the "New"-wizard
- entities grouped by category (is it possible to define sub-categories?
The categories are displayed as a tree, but I couldn't see how to
specify that in the Wizard-wizard.) (Maybe the category explorer should
be optional.)
- a description (it should be sensitive to i18n; is this based on JavaHelp?)
- the way the number of steps are displayed

Is this possible with the current implementation? If yes: how? If not:
do you agree that this wizard should be more generic/ customizable? I
will then open a issue.

-Florian
Back to top
tomwheeler



Joined: 03 Sep 2008
Posts: 950

PostPosted: Thu Oct 23, 2008 4:40 pm    Post subject: Generic New Wizard Reply with quote

I think it is possible if you register your wizard in the Templates
folder of the layer.xml file and be sure to set the
instantiatingIterator attribute to point to the fully-qualified class
name of your WizardDescriptor.InstantiatingIterator subclass that will
be responsible for creating the object(s).

I am pressed for time, so I apologize for not being able to offer a
more complete explanation, but hopefully that will give you enough
info about where to look.

On Thu, Oct 23, 2008 at 4:41 AM, Florian Brunner <address-removed> wrote:
...
Quote:
But I need (and probably others, too) to create some new business objects.
These business objects do not map to files but will be stored in a DB or
sent to an EJB or WebService. The "Projects"-concept does often not exist
and therefore no project-selection component should be presented to the
user. But most of the other requirements are implemented by the existing
"New File"-dialog:

- an extension point to register custom wizards in the "New"-wizard
- entities grouped by category (is it possible to define sub-categories? The
categories are displayed as a tree, but I couldn't see how to specify that
in the Wizard-wizard.) (Maybe the category explorer should be optional.)
- a description (it should be sensitive to i18n; is this based on JavaHelp?)
- the way the number of steps are displayed

Is this possible with the current implementation? If yes: how? If not: do
you agree that this wizard should be more generic/ customizable? I will then
open a issue.




--
Tom Wheeler
http://www.tomwheeler.com/
Back to top
Florian Brunner
Posted via mailing list.





PostPosted: Fri Oct 24, 2008 6:09 pm    Post subject: Generic New Wizard Reply with quote

Hi Tom,

thanks for your answer.

I've seen there are 2 wizards in "Module Development" to register a file
type:
1) File Type: creates & registers a template
2) Wizard (when "New File" is selected in the second panel): registers
the wizard as you described

I still have some open questions, though:
1. How can I react on the "Finish" button (eg. create my objects), when
the wizard is called by the "New File"-action? Would be good to have a
tutorial about this. (At least, I couldn't find one.)
2. How can I customize the "New File"-action? (display text, icon...)
3. How can I remove the project combo box from the first panel displayed
by the "New File"-wizard? (My application does not have a
"Project"-concept.)
4. Where can I find the Javadoc of
org.netbeans.modules.project.ui.actions.NewFile? I couldn't find it...

I guess point 3 is not possible with the current implementation (which
seems to be in the "project" API), right?

-Florian

Tom Wheeler schrieb:
Quote:
I think it is possible if you register your wizard in the Templates
folder of the layer.xml file and be sure to set the
instantiatingIterator attribute to point to the fully-qualified class
name of your WizardDescriptor.InstantiatingIterator subclass that will
be responsible for creating the object(s).

I am pressed for time, so I apologize for not being able to offer a
more complete explanation, but hopefully that will give you enough
info about where to look.

On Thu, Oct 23, 2008 at 4:41 AM, Florian Brunner <address-removed> wrote:
...

Quote:
But I need (and probably others, too) to create some new business objects.
These business objects do not map to files but will be stored in a DB or
sent to an EJB or WebService. The "Projects"-concept does often not exist
and therefore no project-selection component should be presented to the
user. But most of the other requirements are implemented by the existing
"New File"-dialog:

- an extension point to register custom wizards in the "New"-wizard
- entities grouped by category (is it possible to define sub-categories? The
categories are displayed as a tree, but I couldn't see how to specify that
in the Wizard-wizard.) (Maybe the category explorer should be optional.)
- a description (it should be sensitive to i18n; is this based on JavaHelp?)
- the way the number of steps are displayed

Is this possible with the current implementation? If yes: how? If not: do
you agree that this wizard should be more generic/ customizable? I will then
open a issue.





Back to top
tomwheeler



Joined: 03 Sep 2008
Posts: 950

PostPosted: Fri Oct 24, 2008 6:34 pm    Post subject: Generic New Wizard Reply with quote

On Fri, Oct 24, 2008 at 1:09 PM, Florian Brunner <address-removed> wrote:
Quote:
Hi Tom,

thanks for your answer.

I've seen there are 2 wizards in "Module Development" to register a file
type:
1) File Type: creates & registers a template
2) Wizard (when "New File" is selected in the second panel): registers the
wizard as you described

Right. There is no wizard for creating a wizard of the type I
mentioned. You will need to write and integrate the code yourself.

Quote:
I still have some open questions, though:
1. How can I react on the "Finish" button (eg. create my objects), when the
wizard is called by the "New File"-action? Would be good to have a tutorial
about this. (At least, I couldn't find one.)

If you do everything right, the instantiate() method of your
WizardDescriptor.InstantiatingIterator will be called when the user
clicks "finish"; from there, you can run code to create the objects.

It would be nice to have a tutorial about this. I don't think one
exists already.

Quote:
2. How can I customize the "New File"-action? (display text, icon...)

Via various attributes in the layer.xml file, such as
SystemFileSystem.localizingBundle and SystemFileSystem.icon. Sorry to
be vague here, but I just asked on this list yesterday for some
pointers to documentation that explains the attributes you can use. I
don't think there is any, but
you should be able to easily copy the example from any existing module
which defines a wizard for creating new files (i.e. look at the
sources for the IDE).

Quote:
3. How can I remove the project combo box from the first panel displayed by
the "New File"-wizard? (My application does not have a "Project"-concept.)

If you tie into the "New File" wizard, I don't think you can. You
could create a new File menu item which has an action that invokes
your wizard though, and that can have whatever wizard panels you want
to have.

Quote:
4. Where can I find the Javadoc of
org.netbeans.modules.project.ui.actions.NewFile? I couldn't find it...

That is no accident -- it is not a public API. You won't need to use it anyway.

Quote:
I guess point 3 is not possible with the current implementation (which seems
to be in the "project" API), right?

Right, as I described.

--
Tom Wheeler
http://www.tomwheeler.com/
Back to top
Florian Brunner
Posted via mailing list.





PostPosted: Fri Oct 24, 2008 6:59 pm    Post subject: Generic New Wizard Reply with quote

Hi Tom,

thanks again for your answer.


Quote:
Quote:

I've seen there are 2 wizards in "Module Development" to register a file
type:
1) File Type: creates & registers a template
2) Wizard (when "New File" is selected in the second panel): registers the
wizard as you described


Right. There is no wizard for creating a wizard of the type I
mentioned. You will need to write and integrate the code yourself.


I don't understand. The Wizard-Wizard (when "New File" is selected in
the second panel) is doing what you've mentioned, isn't it? Or did I
overlook something? At a second glance it didn't look too file specific...
Quote:
Quote:
I still have some open questions, though:
1. How can I react on the "Finish" button (eg. create my objects), when the
wizard is called by the "New File"-action? Would be good to have a tutorial
about this. (At least, I couldn't find one.)


If you do everything right, the instantiate() method of your
WizardDescriptor.InstantiatingIterator will be called when the user
clicks "finish"; from there, you can run code to create the objects.

It would be nice to have a tutorial about this. I don't think one
exists already.


I'll file an issue for that then.
Quote:
Quote:
2. How can I customize the "New File"-action? (display text, icon...)


Via various attributes in the layer.xml file, such as
SystemFileSystem.localizingBundle and SystemFileSystem.icon. Sorry to
be vague here, but I just asked on this list yesterday for some
pointers to documentation that explains the attributes you can use. I
don't think there is any, but
you should be able to easily copy the example from any existing module
which defines a wizard for creating new files (i.e. look at the
sources for the IDE).


Is there already an open issue for this? Or does someone else know where
to find the documentation?
Quote:
Quote:
3. How can I remove the project combo box from the first panel displayed by
the "New File"-wizard? (My application does not have a "Project"-concept.)


If you tie into the "New File" wizard, I don't think you can. You
could create a new File menu item which has an action that invokes
your wizard though, and that can have whatever wizard panels you want
to have.


I think I will open an issue for that, too, since most of the existing
New File-wizard could be reused. Especially if the first panel could be
customized a little more, this would help a lot.
Quote:
Quote:
4. Where can I find the Javadoc of
org.netbeans.modules.project.ui.actions.NewFile? I couldn't find it...


That is no accident -- it is not a public API. You won't need to use it anyway.


Well, at least I have to register it in my application. ;-)

-Florian
Back to top
tomwheeler



Joined: 03 Sep 2008
Posts: 950

PostPosted: Fri Oct 24, 2008 7:47 pm    Post subject: Generic New Wizard Reply with quote

On Fri, Oct 24, 2008 at 1:59 PM, Florian Brunner <address-removed> wrote:
Quote:
I don't understand. The Wizard-Wizard (when "New File" is selected in the
second panel) is doing what you've mentioned, isn't it? Or did I overlook
something? At a second glance it didn't look too file specific...

My mistake -- you are correct. In my application, I have a subclass
of WizardDescriptor.InstantiatingIterator that I created to better
integrate with some custom APIs in our project. It has been a while
since I had used the wizard-wizard for new File creation and did not
realize that it uses WizardDescriptor.InstantiatingIterator.

Well, this makes it easier for you :-)

Quote:
Quote:
It would be nice to have a tutorial about this. I don't think one
exists already.

I'll file an issue for that then.

Great -- put me (tomwheeler) on the cc list after you create it. I
don't have time to write such a tutorial now, but maybe I can help
with one if I find some free time.

Quote:
Quote:
...but I just asked on this list yesterday for some pointers to documentation
that explains the attributes you can use. I don't think there is any, but
you should be able to easily copy the example from any existing module
which defines a wizard for creating new files (i.e. look at the
sources for the IDE).

Is there already an open issue for this? Or does someone else know where to
find the documentation?

Ivan replied to my query to suggest a few things, but there was no
definitive answer. So I take this to mean that no one has ever really
documented it. I know of no open issue for this, but if you file one,
please put me (tomwheeler) on the cc list in case I can help to
document it in the future.

Quote:
Quote:
That is no accident -- it is not a public API. You won't need to use it
anyway.

Well, at least I have to register it in my application. Wink

Ahh. As the name implies, it's in the project UI module. If you
don't really have the concept of a project in your application, you
probably don't have that module enabled. In that case, you might be
better off registering an instance of
org.openide.actions.NewTemplateAction, which is defined in the Actions
API. Doing that may also solve your need to modify the existing
wizard panels to take out the project-related panel.

--
Tom Wheeler
http://www.tomwheeler.com/
Back to top
Florian Brunner
Posted via mailing list.





PostPosted: Sat Oct 25, 2008 11:43 am    Post subject: Generic New Wizard Reply with quote

Hi Tom,

Quote:
Ahh. As the name implies, it's in the project UI module. If you
don't really have the concept of a project in your application, you
probably don't have that module enabled. In that case, you might be
better off registering an instance of
org.openide.actions.NewTemplateAction, which is defined in the Actions
API. Doing that may also solve your need to modify the existing
wizard panels to take out the project-related panel.

thanks, I've tried that now, but I only get a peep-sound, when selecting the
menu item. No dialog opens. Here's my change to the layer file:
-----------------------------------------
<folder name="Actions">
<folder name="Edit">
...
<file name="org-openide-actions-NewTemplateAction.instance"/>
...
</folder>
...
</folder>

<folder name="Menu">
<folder name="File">
...
<file name="org-openide-actions-NewTemplateAction.shadow">
<attr name="originalFile"
stringvalue="Actions/Edit/org-openide-actions-NewTemplateAction.instance"/>
<attr name="position" intvalue="1200"/>
</file>
...
</folder>
...
</folder>

<folder name="Templates">
<folder name="test">
<file name="test">
<attr name="SystemFileSystem.localizingBundle"
stringvalue="mypackage.Bundle"/>
<attr name="instantiatingIterator"
newvalue="mypackage.TestWizardIterator"/>
<attr name="template" boolvalue="true"/>
<attr name="templateWizardURL"
urlvalue="nbresloc:/mypackage/test.html"/>
</file>
</folder>
</folder>
-----------------------------------------

Interestingly the NewTemplateAction is a NodeAction, but is still always
enabled, even if no node is selected (which is what I want).

Also note that the NewTemplateAction despite to its package name is not define
in the Actions API but in the Datasystems API. Note that I don't work with
FileObjects and DataObjects. Should I still use this NewTemplateAction? How
can I make it work?

I also tried the NewAction from the Actions API. It's also a NodeAction, is
displayed as "Add" in the menu by default and is always disabled. :-/

-Florian
Back to top
tomwheeler



Joined: 03 Sep 2008
Posts: 950

PostPosted: Mon Oct 27, 2008 3:09 am    Post subject: Generic New Wizard Reply with quote

On Sat, Oct 25, 2008 at 6:45 AM, Florian Brunner <address-removed> wrote:
...
Quote:
Also note that the NewTemplateAction despite to its package name is not define
in the Actions API but in the Datasystems API. Note that I don't work with
FileObjects and DataObjects. Should I still use this NewTemplateAction? How
can I make it work?

I realized you did not want to use the Project API, but I did not know
you were also avoiding FileObjects and DataObjects. In this case, I
don't think NewTemplateAction would be an appropriate choice.

I'm sure it's still possible to do what you want, but I have not done
exactly this before and so I'm not in a good position to help you. I
guess if it were me, I'd create and register a stateless action (e.g.
CallableSystemAction) which brought up a dialog that allowed me to
choose the type of object to create, then invoked the relevant
instantiating wizard to actually create it. In other words, you will
need to do more or less the same thing which the File -> New File
infrastructure does, but without any assumptions about using files.

Hopefully someone else on this list will have done the same thing and
could give you further advice. Meanwhile, it shouldn't be *too* hard
since there are wizards which will generate much of this code for you.

Good luck!

--
Tom Wheeler
http://www.tomwheeler.com/
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo