Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » init() method in Wizard not getting called(Problem in creating Wizard)
init() method in Wizard not getting called [message #664860] Tue, 12 April 2011 10:31 Go to next message
Saurabh  is currently offline Saurabh Friend
Messages: 8
Registered: April 2011
Junior Member
I am trying to create a Wizard, My Wizard class looks like:

....
public class DocumentBasicView extends Wizard implements INewWizard {
....

I've defined some intialisation code for my Wizard Page in my "init()" method (overriding the IWorkbenchWizard class's init() method), like this:

....
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
fpage = new BasicViewPage(workbench, selection);
....

After which, I add it in the "addPages()" method.

But, my init() method never gets called !! (as specified in the API)
Because of this, my Page remains uninitialized, and it throws a NullPointerException.

I absolutely require the init() method to be called, as my Page's initialisation requires the workbench and selection variables.

Can anybody help me out? Why isn't the init() method getting called?
I am using Eclipse version 3.6.2

I can post the full code, if anyone can help !!
Re: init() method in Wizard not getting called [message #664869 is a reply to message #664860] Tue, 12 April 2011 10:40 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
On 2011-04-12 12:31, Saurabh wrote:
> I am trying to create a Wizard, My Wizard class looks like:
>
> ...
> public class DocumentBasicView extends Wizard implements INewWizard {
> ...
>
> I've defined some intialisation code for my Wizard Page in my "init()"
> method (overriding the IWorkbenchWizard class's init() method), like this:
>
> ...
> @Override
> public void init(IWorkbench workbench, IStructuredSelection selection) {
> fpage = new BasicViewPage(workbench, selection);
> ...
>
> After which, I add it in the "addPages()" method.
> But, my init() method never gets called !! (as specified in the API)
> Because of this, my Page remains uninitialized, and it throws a
> NullPointerException.
>
> I absolutely require the init() method to be called, as my Page's
> initialisation requires the workbench and selection variables.
>
> Can anybody help me out? Why isn't the init() method getting called?
> I am using Eclipse version 3.6.2
>
> I can post the full code, if anyone can help !!

The init() method is called by the framework, if your wizard is
configured by extension point. I won't be automatically called, if you
start the wizard programmatically. So, if the method is not called, my
assumption is that you open the wizard by code instead. In this case it
is your responsibility to invoke init() at the right point in time,
because you have decided to define the life-cycle.

HTH & Greetings from Bremen,

Daniel Krügler
Re: init() method in Wizard not getting called [message #664874 is a reply to message #664869] Tue, 12 April 2011 11:07 Go to previous messageGo to next message
Saurabh  is currently offline Saurabh Friend
Messages: 8
Registered: April 2011
Junior Member
Thanks a lot for replying...

In that case, can you please guide me how should I use the Extension Point here? I tried it first, but failed.

I am designing a simple RCP actually, and just need a "File" menu (which I created using PDE via Extension Points) . In the File Menu, I want to add Commands, which can run my wizards. A structure like:

File
---Create New X Document
---Create New Y Document
---Exit

I created the Exit button, with the help of Online Tutorials.
I have written codes for Wizards X and Y. But just not getting the options in PDE to add a Wizard to the File Menu.

I'll be grateful if you tell me how can I do so.

Regards,
Saurabh Srivastava,
IIT Kanpur, India
Re: init() method in Wizard not getting called [message #664885 is a reply to message #664874] Tue, 12 April 2011 12:16 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
On 2011-04-12 13:07, Saurabh wrote:
> Thanks a lot for replying...
>
> In that case, can you please guide me how should I use the Extension
> Point here? I tried it first, but failed.

As described in the Eclipse help,

http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/dialogs_wizards_newWizards.htm

the NewWizard extension point can be used, if you want to participate as
part of the File>New menu.

> I am designing a simple RCP actually, and just need a "File" menu (which
> I created using PDE via Extension Points) . In the File Menu, I want to
> add Commands, which can run my wizards. A structure like:
>
> File
> ---Create New X Document
> ---Create New Y Document
> ---Exit
>
> I created the Exit button, with the help of Online Tutorials.
> I have written codes for Wizards X and Y. But just not getting the
> options in PDE to add a Wizard to the File Menu.
>
> I'll be grateful if you tell me how can I do so.

If you want to reuse the provided service for new-wizards, you should
try to follow the description given in the help quoted above, otherwise
you need to construct the dialog manually, including the invocation of
the init() function, if you really need it.

HTH & Greetings from Bremen,

Daniel Krügler
Re: init() method in Wizard not getting called [message #664962 is a reply to message #664874] Tue, 12 April 2011 15:06 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
On 12/04/11 4:37 PM, Saurabh wrote:
> I am designing a simple RCP actually, and just need a "File" menu (which
> I created using PDE via Extension Points) . In the File Menu, I want to
> add Commands, which can run my wizards. A structure like:
>
> File
> ---Create New X Document
> ---Create New Y Document
> ---Exit

See
http://eclipse-tips.com/tips/37-contributing-workbench-wizar ds-thru-commands
for how to add those wizards via commands.

--
- Prakash
Platform UI Team, IBM

www.eclipse-tips.com
Re: init() method in Wizard not getting called [message #665355 is a reply to message #664962] Thu, 14 April 2011 12:31 Go to previous messageGo to next message
Saurabh  is currently offline Saurabh Friend
Messages: 8
Registered: April 2011
Junior Member
Hi,
Thanks to both of you...

I solved my problem by adding the Default Actions in the ActionFactory Class, to my File Menu.

Thanks a lot for replying Smile

Saurabh
Re: init() method in Wizard not getting called [message #665356 is a reply to message #664885] Thu, 14 April 2011 12:33 Go to previous message
Saurabh  is currently offline Saurabh Friend
Messages: 8
Registered: April 2011
Junior Member
Thanks Daniel for your reply..
My problem is solved..

Cheers,
Saurabh
Previous Topic:"Premature end of file" during product builds
Next Topic:How to set a Windows System Environment Variable for a plug-in
Goto Forum:
  


Current Time: Wed Aug 12 16:21:12 GMT 2020

Powered by FUDForum. Page generated in 0.01590 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top