Bug 411821 - [QuickAccess] Contribute SearchField through a fragment or other means
Summary: [QuickAccess] Contribute SearchField through a fragment or other means
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2   Edit
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Target Milestone: 4.4 M5   Edit
Assignee: Paul Webster CLA
QA Contact: Daniel Rolka CLA
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2013-06-27 14:54 EDT by Paul Webster CLA
Modified: 2018-11-07 09:29 EST (History)
12 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Webster CLA 2013-06-27 14:54:31 EDT
From bug 362420: For having it in the trim or not this is indeed simple and just requires what we move some (all) of the model elements we currently add by code into the LegacyIDE model itself. This would allow RCP developers that don't want it in the trim to simply remove it form the model.

We should contribute the SearchField through a fragment or an MTrimContribution/MToolbarContribution, something that can be wired off by RCP applications that don't want it.

PW
Comment 1 Eric Moffatt CLA 2013-10-04 14:05:06 EDT
One problem with this is that at least some folks don't want to lose the functionality, just the trim (i.e. they want it to work like in did before we introduced the trim widget).

I'm certainly +1 that the starting LegacyIDE.xmi should contain *all* non-contributed elements and code like 'populateTopTrim'...should be removed.
Comment 2 Lars Vogel CLA 2013-11-05 09:46:44 EST
If we move it to a model fragment in a separate plug-in, RCP application could decide if they want to have that feature included. This would solve the complains of 3.X RCP application that they get the search box after switching to Eclipse 4.
Comment 3 Daniel Horrisberger CLA 2013-11-05 12:17:42 EST
Agree with Lars Vogel
Comment 4 Missing name Mising name CLA 2013-11-29 14:23:42 EST
I've tried to move the code of the quick-access to a separate bundle, but it seams that this implementation uses a lot of internal classes from the workbench, e.g.:

org.eclipse.ui.internal.keys.BindingService
org.eclipse.ui.internal.menus.CommandMessages
org.eclipse.ui.internal.misc.StatusUtil
org.eclipse.ui.internal.IWorkbenchGraphicConstants
org.eclipse.ui.internal.WorkbenchImages
org.eclipse.ui.internal.WorkbenchWindow
org.eclipse.ui.internal.Workbench
org.eclipse.ui.internal.WorkbenchMessages
org.eclipse.ui.internal.WorkbenchPlugin
org.eclipse.ui.internal.dialogs.WorkbenchPreferenceDialog
org.eclipse.ui.internal.dialogs.PropertyPageContributorManager
org.eclipse.ui.internal.dialogs.PropertyPageManager
org.eclipse.ui.internal.e4.compatibility.CompatibilityPart
...

So I think a simple extract and organize of the imports isn't a solution, because it would require x-Friends.

It is also not possible to extend the list of providers because they are hard-coded.

Maybe it's better to:
* create a new extension point to provide QuickAccessProviders
* register the current hard-coded providers via the new extension point and remove their hard-wiring
* re-implement the SearchField and it's functionality into a new plug-in which uses the new extension point to provide the data to the user

This would make the SearchField optional and extensible for other plugins.
Comment 5 Timo Kinnunen CLA 2013-11-30 05:37:52 EST
(In reply to comment #4)
> This would make the SearchField optional and extensible for other plugins.

I like the sound of that. Many times I've wanted to type a potential class name into that search field just to see if something resembling it turns up. There's the search dialog, but this could be so much simpler and smarter.
Comment 6 Paul Webster CLA 2013-12-02 11:31:46 EST
There are other bugs about QuickAccess extensibility.  That's not this one.

René, thanks for taking a crack that this.  But all of QuickAccess doesn't need to be factored out to satisfy the constraints for this bug.

Option 1:  Contribute QuickAccess through a fragment in org.eclipse.ui.ide.application that adds it  in the correct location.  The IDE will get it, and RCP apps won't.  Any RCP apps that want it can add it themselves.

Option 2: Tie the contribution of the SearchField to a tag on the MTrimmedWindow somehow.

PW
Comment 7 Missing name Mising name CLA 2013-12-06 14:16:35 EST
(In reply to Paul Webster from comment #6)
> There are other bugs about QuickAccess extensibility.  That's not this one.
Sorry I didn't realized that there is already a bug for this.

> 
> René, thanks for taking a crack that this.  But all of QuickAccess doesn't
> need to be factored out to satisfy the constraints for this bug.
> 
> Option 1:  Contribute QuickAccess through a fragment in
> org.eclipse.ui.ide.application that adds it  in the correct location.  The
> IDE will get it, and RCP apps won't.  Any RCP apps that want it can add it
> themselves.
> 
> Option 2: Tie the contribution of the SearchField to a tag on the
> MTrimmedWindow somehow.
> 
> PW

So finally I found a solution for this, which allows you to contribute the QuickAccess to your Workbench via an application model fragment. It wasn't that easy as I thought, because nearly all of the model contribution stuff in the "org.eclipse.ui.workbench" is done via code and not via the LegacyIDE.e4xmi. This means after all the e4 application model processing (fragment, processor, ...) is done the workbench starts to contribute its elements via code and so all my contributions weren't in the model ;-(

But I finally found a way, which can put the QuickAccess into any of the four sidebars.

So have a look at: https://git.eclipse.org/r/19454
Comment 8 Paul Webster CLA 2013-12-06 14:46:31 EST
(In reply to René Brandstetter from comment #7)
> But I finally found a way, which can put the QuickAccess into any of the
> four sidebars.
> 
> So have a look at: https://git.eclipse.org/r/19454

Does it work if you open a second workbench window from Window>New Window?  Is it easy for an RCP app to not pick up the search bar?

PW
Comment 9 Missing name Mising name CLA 2013-12-07 14:05:43 EST
(In reply to Paul Webster from comment #8)
> (In reply to René Brandstetter from comment #7)
> > But I finally found a way, which can put the QuickAccess into any of the
> > four sidebars.
> > 
> > So have a look at: https://git.eclipse.org/r/19454
> 
> Does it work if you open a second workbench window from Window>New Window?
Yes, the new version on Gerrit does provide the QuickAccess in the second workbench window. I had to put the QuickAccess elements into a TrimContribution inside of the application fragment e4xmi. Thanks for the hint.

> Is it easy for an RCP app to not pick up the search bar?
If a RCP app doesn't provide the QuickAccess element in its model, than it will not be visible. So the default is no QuickAcces, easy enough? :)

I've took your suggestion and put the contribution only into the "org.eclipse.ui.ide.application". This bundle provides a new application model fragment named "LegacyIDE_fragment.e4xmi" which contains a TrimContribution for the main toolbar. The TrimContribution puts the ToolControls of the QuickAccess into the main tool bar and the WorkbenchWindow#positionQuickAccess() method moves them to the correct location.

This move-step is required because the default "position in list" of the TrimContribution doesn't work, due the fact that the reference element (=after:PerspectiveSpacer) is added via code long time after the "position in list" has been called.

> 
> PW
Comment 11 Brian de Alwis CLA 2014-01-13 16:31:30 EST
This functionality is useful for non-IDE RCP apps though.
Comment 12 Paul Webster CLA 2014-01-13 16:36:22 EST
They can contribute it through their own fragment.  The difference now is it's not for free

PW
Comment 13 Lars Vogel CLA 2014-01-21 04:42:51 EST
Verified in I20140120-2000.
Comment 14 Thomas Schindl CLA 2014-01-21 06:17:13 EST
I think this fix is the cause for bug 426224
Comment 15 Thomas Schindl CLA 2014-01-21 06:18:24 EST
Instead of using a fragment you could use a processor!
Comment 16 Missing name Mising name CLA 2014-01-21 13:53:23 EST
Yes but with the processor it's harder to position the elements to a specific place and as I wrote already in https://bugs.eclipse.org/bugs/show_bug.cgi?id=426224#c5 there is a clean-up of the legacy elements. I will check if there is a problem with it.
Comment 17 Paul Webster CLA 2014-01-21 13:59:50 EST
(In reply to René Brandstetter from comment #16)
> Yes but with the processor it's harder to position the elements to a
> specific place and as I wrote already in
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=426224#c5 there is a clean-up
> of the legacy elements. I will check if there is a problem with it.

No, it's OK, I'll explain in the other bug

PW