Eclipse SearchDialog Changes as soon as the Dialog is being called - eclipse

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".

Related

Double clicking a resource in Eclipse Project Explorer does not open the second file

In an Eclipse based application (RCP), when double clicking on a file that appears in the project explorer, for the first file this will work – the associated editor will open. However, when double clicking again on a file, it will not open. If you click somewhere out of the Project Explorer and then return to the Project Explorer, then the second double click will work.
Note that right-clicking on the resource and selecting “Open” always works. In addition, in Package Explorer it always works.
I believe this is related to eclipse bugs 285239 and 256761.
Does anyone know of a way that I can overcome this problem, as the RCP developer. The file editor is a custom editor in one of my plugins.
The problem does not seem to happen to me with java files in standard eclipse for java development.
Thanks,
Eyal.
I solved the problem by implementing a setFocus method on the editor class. In the setFocus, I set the focus to some component. (To be precise in my case the editor was a subclass of SharedHeaderFormEditor so I set the focus to the active page).
The truth is that the specification of the setFocus method in IWorkbenchPart requires you to "assign the focus to one of the controls contained in the part's parent composite". It seems that the default implementation of setFocus in some cases did not do that (I don't know why, maybe I was missing something or for other reason).
Note that also setting focus explicitly to a control from within editor initializing partialy solves the problem.

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

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 !

Can I disable the refactor preview in Eclipse?

When renaming a variable using Eclipse, I always get a popup dialog showing me a preview of the refactoring. Is there some way I can disable this popup dialog? In other words, I want to place the cursor over a variable name, press alt+shift+r, edit the variable name, press enter, and have the renaming take place without ever seeing the preview. Is there some preference or setting for this?
I"m using Eclipse 3.6 (Helios)
UPDATE:
To test this, I did the following. I created a new Java Project and added the following class to the package.
public class TestRename{
private int var;
}
This is the only code in the project and still when I try to rename var I get a preview dialog in which I have to click "OK" to make the change. I'm pretty sure this wasn't the default behavior in Eclipse, but I must have edited the defaults somehow. I just don't know what I did or how to reset the preview behavior of the refactor.
There is a preference under "Java" for this called "Rename in editor without dialog". If this is not selected, the rename dialog will show up every time.
I'm also using Helios, a dialog only appears when you are potentially creating a name conflict or refactoring code that has compile errors.

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.

how to access package explorer element in eclipse plugin

i am making an eclipse plugin which make a ui on right clicking a project in eclipse workspce . the ui contains text fields , package explorer for the current project and directory explorer for current project.
i have successfully made a ui which appears on clicking a menu item on right clicking the project but it seems i can't make any jface or swt ui since they are not visible when we are using eclipse command hadlers .so in order to overcome it i made dialog pages but they have limited dialog like directorty dialog and file dialog and that too for entire window directory..... but i want package explorer and directory explorer for the project i just chose like it happens when u try making a new class in a project the browse buttons just show packages and directory struture w.r.t to current selection
am i doin things wrong or is there a way out please suggest .....
It seems a bit unclear to me, what the 'UI' is about. If you plan to embed the package and directory views inside a dialog next to each other, then I think you have to build similar lists on your own, since they are views with their own event logic. But if you plan to use them via the browse buttons as describes, take a look at this page. It gives a good overview of the available selection dialogs in eclipse.
It is also always a good practice to search for code in eclipse that does nearly the same you want to do.
As an example, take a look at the new class wizard from the jdt.ui plug-in (This is the wizard you mentioned in your question): Press Cmd-Shift-T and begin typing 'newclass' and open NewClassWizardPage from org.eclipse.jdt.ui.wizards. This works as expected if you imported all jdt plug-ins as (binary) projects.
Take a look at the createControl method and dive into the createXXXControls methods via F3 and try to find out how JDT is doing the job.
As an alternative, open the desired selection dialog class (again with Cmd-Shift-T) and open the call hierarchy of that class...