How can I launch a wizard from code? [message #286877] |
Mon, 20 June 2005 17:37  |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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é
|
|
|
Powered by
FUDForum. Page generated in 0.37454 seconds