Eclipse Plugin: How to modify the extension "org.eclipse.ui.newWizards"? - eclipse

I have a wizard that should be launched in different ways: from the menu (org.eclipse.ui.menus + org.eclipse.ui.actionSets) and from the New context menu. For the later I used the extension org.eclipse.ui.newWizards to add the wizard into the context menu. So far, so good...
For some reasons I had to subclass the wizard dialog (changed the finish button text in the dialog). If the wizard is launched from the menu, the action (defined in org.eclipse.ui.actionSets) creates and opens this special wizard dialog and everything is fine.
If the wizard is launched from the context menu (org.eclipse.ui.newWizards), the internal class NewWizardShortcutAction is taken that creates the "normal" wizard dialog (and not my subclass) to open the wizard.
Is there any way to modify the implementation of the extension point that only my subclassed wizard dialog is used?

By default the command uses org.eclipse.ui.internal.handlers.WizardHandler.New to launch the new wizard dialog, and that's the default handler provided to the command.
It would be possible to register a different handler at the Workbench Window level, and that would override the default handler while a Workbench Window was active. It could be done in the plugin.xml or in your application ActionBarAdvisor:
IHandlerService hs = (IHandlerService) window.getService(IHandlerService.class);
hs.activateHandler(IWorkbenchCommandConstants.FILE_NEW, new MyNewHandler());
But you would have to implement whatever support was needed in the handler to launch the wizard with the correct selection.

I'm also trying to do the same. The way I will be doing this is to register my own custom action, by removing the old action, will post back the solution if it works !
Update: I ended up using a different approach. If you see the run method in NewWizardShortcutAction, it is just calling init, creating the WizardDialog and opening it. So in my override of the init in MyWizard class, I just used my own MyWizardDialog extending from WizardDialog and opened it. Subsequently, I need to make that the run function will not re-open the WizardDialog, so I track that using a boolean in MyWizard that will disallow getting any pages so that the WizardDialog in the run method will not be displayed.
This is a hacky solution but works !

Related

How can I close a property window in an application developed with RCP?

I'm having a bit of a trouble modifying an application that I have inherited from another party. The application is a Front End made with Eclipse RCP, and I have to modify one of its property windows so when I click a Save button it will not just save the data to my database, but also close that property window.
I can't find a way to reference the window itself so I can invoke a method like "window.close();", would anyone have a hint by any chance?
Thank you.

How to remove toolbar created by eclipse 4 application wizard (RCP)

When i create an eclipse 4 application using the wizard it automatically creates these default toolbar and menus.
It seems that whatever i do they just stay there.
I cannot modify them and the only thing that works is modifying the handler's code.
The reason is that the workspace is not updated for some reason so what i did is marked the "clear workspace data" checkbox on the launch config and it is solved

Key binding to popup menu item in eclipse Helios?

In our project at work, they have written one plug-in for eclipse helios. They have used the
objectContribution for adding the popups and written respective action classes for them.
I am trying to add the shortcut key for one of the popup menu item in project explorer.
But I read here http://www.eclipse.org/forums/index.php/mv/tree/172398/#page_top that there is no way to call key bindings from objectContribution and need to migrate it to handlers/commands.
Is there any other way to bind keys to popups instead of migrate them to handlers?
Thanks in advance!!
No, objectContributions cannot accept keybindings. From legacy action extension points, only actionSets accept keybindings correctly.
The other option available (as mentioned) is to provide a handler for the command you want. The handler won't interfere with the objectContribution behaviour (the objectContribution action delegate class will still be called directly from the menu item, the handler would be called when using a keybinding).
PW

Eclipse SearchDialog Changes as soon as the Dialog is being called

My Requirement is like to change the Eclipse Default SearchDialog, so as soon as any user opens the Eclipse Menu , Search>Search, the window/wizard opens should be the customized one ,
How to make this scenario possible.
Is there any Extension point which handles all startup operation for a wizard, so that I could call that and any time the dialog is getting called , I will override and make my changes.
By using org.eclipse.search.searchResultViewPages extension point you can define your own search result page and other required class to contribute to the built-in Eclipse search "mechanism".

Activate the activator class

I am using eclipse 3.6. I created one sample plugin application. It is neither a eclipse rcp nor workbench. Now when I run the eclipse I want that plugin also to be loaded. But I dont want to use IStartUp. Because what I have found out is
IStartup will be called after the workbench is loaded. I want to refresh some menu. So Is there any way to activate my plugin while the eclipse loaded?
I tried to use Bundle Activation policy. But that is also not activating my Activator class. I just put one System.out. println("Inside start()"). So that is not called. Now can I make it activate my activator?
EDIT:
what my exact requirement is, I have created one workbench application.It is not eclipse rcp application. Now I want to remove the following menu and menu items from the eclipse before the eclipe is loaded.
1. File Menu
2.) Search Menu
3.)Run Menu
4.)Help->search,Dynamic Help,Key assist,Tips and trick,Report Bug,Cheat Sheet.
These menus are inbuilt menu of eclipse. So that is the reason I have to do in this way.
So I already implemented by using startup extension point. But the early startup is called after the eclipse is started.So I need to do some refreshment on the workbench.Then only the menu item will get removed.So I thought I need startup extension point will not satisfy my requirement as it doesnot refresh the workbench.I need to activate the my plugin and refresh the workbench before it is loaded.
Thanks
Bhanu
You can set the needed start level for your plugin using touch point instruction.
You are just a plugin that expects to run in the Eclipse IDE?
Then the answer is, you cannot do what you want.
If you start before the workbench has finished initializing, most of the services that could be used won't work: The workbench itself, menu service, command service, etc.
For most plugins in eclipse, the plugin.xml should be used to add menus, views, editors, etc to eclipse. When necessary, the framework will instantiate them.
org.eclipse.ui.IStartup is available and as you mentioned it will be called after the workbench has been initialized, but before any windows have been shown. It's not to be used lightly, and not by plugins contributing to the UI as it allows all extension from that plugin to be loaded.
EDIT:
If you are an RCP app, you control the main menu. As an RCP app, you have access to the ActionBarAdvisor, WorkbenchAdvisor, WorkbenchWindowAdvisor, which all have lifecycle methods.
If you are an an eclipse plugin, you can add to the main menu ... you cannot easily remove from the main menu. This is by design. Start levels and org.eclipse.ui.startup are 2 mechanisms that won't do what you want.
You still need to answer these questions:
There might still be a way. The crux of your problem is: "I want to refresh some menu"
What kind of menu (popup, main menu,
compound list of menu items in a
menu, etc)?
Where is the menu contribution coming from?
Which specific menu item is it?
Please edit your question (do not comment) and include the information from the above 3 questions, please.