Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » How can I launch a wizard from code?
How can I launch a wizard from code? [message #286877] Mon, 20 June 2005 17:37 Go to next message
Eclipse UserFriend
Originally posted by: pbeagan.yahoo_nospam_.com

Anyone know what code is needed to launch a wizard?.
Specifically, I want the user to be able to right-click on the Project
Explorer, select a menu item 'MyWizard', and have the wizard start.
Creating the popupMenu IViewActionDelegate object is straightforward,
I figure I can just put some code in the run() menu to invoke 'MyWizard'.

I put the following code in the run() method but it leads to the exception
below:

INewWizard wiz = new MyWizard();
wiz.init(PlatformUI.getWorkbench(), null);



Unhandled event loop exception
Reason:
myproj/eclipse/project/wizard/MyWizard




Thanks!
Re: How can I launch a wizard from code? [message #286970 is a reply to message #286877] Wed, 22 June 2005 05:19 Go to previous message
Eclipse UserFriend
Originally posted by: rm.triadem.ch

Patrick Beagan wrote:
> Anyone know what code is needed to launch a wizard?.
> Specifically, I want the user to be able to right-click on the Project
> Explorer, select a menu item 'MyWizard', and have the wizard start.
> Creating the popupMenu IViewActionDelegate object is straightforward,
> I figure I can just put some code in the run() menu to invoke 'MyWizard'.
>
> I put the following code in the run() method but it leads to the exception
> below:
>
> INewWizard wiz = new MyWizard();
> wiz.init(PlatformUI.getWorkbench(), null);

This works for me:

public class MyAction implements IWorkbenchWindowActionDelegate {

private ISelection currentSelection;

public void run(IAction action) {
if(currentSelection instanceof IStructuredSelection) {
NewModelWizard wizard = new NewModelWizard();
wizard.init(
PlatformUI.getWorkbench(),
(IStructuredSelection) currentSelection);
}
}

public void selectionChanged(IAction action, ISelection selection) {
currentSelection = selection;
}
}

....where NewModelWizard is
public class NewModelWizard extends Wizard implements INewWizard {...}


HTH René
Previous Topic:How can i make an Eclipse plug-in from a C++ application?
Next Topic:Using the Eclipse code formatter on .java files
Goto Forum:
  


Current Time: Fri Jul 18 20:42:41 EDT 2025

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

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

Back to the top