Community
Participate
Working Groups
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.
Assigning to our quick access master.
The attached change adds a quick access entry: "Search '<filter>' in Workspace" see: https://git.eclipse.org/r/#/c/80483/
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?
New Gerrit change created: https://git.eclipse.org/r/80483
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);
Ergo, with the patchset 5, I'm using the command org.eclipse.search.ui.performTextSearchWorkspace.
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.
We shouldn't add special code for some actions. There is the 'Find Text in Workspace' command which does exactly that via Quick Access.
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
(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.