Bug 500833 - [QuickAccess] Allow Text search
Summary: [QuickAccess] Allow Text search
Status: RESOLVED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.6   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Patrik Suzzi CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted, noteworthy
Depends on:
Blocks:
 
Reported: 2016-09-05 04:37 EDT by Lars Vogel CLA
Modified: 2016-09-08 09:50 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2016-09-05 04:37:42 EDT
Similar to the "Search in Help" I think it would be an awesome enhancement if the user, can trigger a text search via Quick Access. 

I think we should also add a "always available" entry "Search text in workspace" or something similiar which performs a regular expression based text search.
Comment 1 Lars Vogel CLA 2016-09-05 04:38:14 EDT
Assigning to our quick access master.
Comment 2 Patrik Suzzi CLA 2016-09-06 10:00:09 EDT
The attached change adds a quick access entry: "Search '<filter>' in Workspace" 
see: https://git.eclipse.org/r/#/c/80483/
Comment 3 Patrik Suzzi CLA 2016-09-06 10:09:39 EDT
The search should trigger the "org.eclipse.search.ui.performTextSearchWorkspace" Action, the same triggered by CTRL+ALT+G.

The above command is defined in org.eclipse.search project (eclipse.platform.text repo), hence it is not clear to me how I'm supposed to invoke that command from the "org.eclipse.ui.workbench" that belong to another repository (eclipse.platform.ui ) 

Could you please suggest what is the best practice to invoke the "performTextSearchWorkspace" command, passing a text to that command?
Comment 4 Eclipse Genie CLA 2016-09-06 16:50:30 EDT
New Gerrit change created: https://git.eclipse.org/r/80483
Comment 5 Patrik Suzzi CLA 2016-09-06 21:02:17 EDT
With the latest change, https://git.eclipse.org/r/#/c/80483/4/, I can invoke the search command org.eclipse.search.ui.performTextSearchWorkingSet, but I'm not yet able to pass the search text as the argument. As a result, in the UI I get the error message: "Could not evaluate a text selection"
see: http://imgur.com/PnbOQR4.png


Below you see the code to invoke the command. 
Do you have suggestions on how to pass the searchText as parameter ?


// Retrieve the Services
ECommandService cs = PlatformUI.getWorkbench().getService(ECommandService.class);
IHandlerService hs = PlatformUI.getWorkbench().getService(IHandlerService.class);

// Retrieve the command
Command cmd = cs.getCommand(SEARCH_TEXT_IN_WORKSPACE_ACTION_ID);

// specify the selection
IEvaluationContext c = hs.createContextSnapshot(false);
IStructuredSelection iss = new StructuredSelection(new String[]{searchText, null});
c.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, iss);

// execute
hs.executeCommandInContext(new ParameterizedCommand(cmd, null), null, c);
Comment 6 Patrik Suzzi CLA 2016-09-06 21:08:37 EDT
Ergo, with the patchset 5, I'm using the command org.eclipse.search.ui.performTextSearchWorkspace.
Comment 7 Patrik Suzzi CLA 2016-09-07 18:11:09 EDT
I really spent too much time trying to figure out how to fake a text selection to be recognized by the performTextSearchWorkspace command.

I'll park this item for a while. Any suggestion could be decisive to push the fix.
Comment 8 Dani Megert CLA 2016-09-08 09:25:52 EDT
We shouldn't add special code for some actions. There is the 'Find Text in Workspace' command which does exactly that via Quick Access.
Comment 9 Patrik Suzzi CLA 2016-09-08 09:43:14 EDT
Ehm, the 'Find Text in Workspace' command has the same issue, the 'text to find' comes from the current selection, i.e. in the editor. 

Please see animation: http://imgur.com/wo2VJEX.gif
Comment 10 Dani Megert CLA 2016-09-08 09:50:13 EDT
(In reply to Patrik Suzzi from comment #9)
> Ehm, the 'Find Text in Workspace' command has the same issue, the 'text to
> find' comes from the current selection, i.e. in the editor. 
> 
> Please see animation: http://imgur.com/wo2VJEX.gif

Yes. But again, duplicating existing commands seems overkill. I then want search in JDT (workspace, project, file). Search in CDT. Search in PHP. Search in JavaScript, etc.