Bug 33710 - Open Search dialog with previous page instead of using the current selection to detect the page
Summary: Open Search dialog with previous page instead of using the current selection ...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Search (show other bugs)
Version: 2.1   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 4.3 M6   Edit
Assignee: Marco Descher CLA
QA Contact:
URL:
Whiteboard:
Keywords: bugday
: 34680 48103 237160 279741 331617 351583 395453 397385 (view as bug list)
Depends on:
Blocks: 568786
  Show dependency tree
 
Reported: 2003-03-03 17:49 EST by Pradeep Kanwar CLA
Modified: 2020-11-13 05:27 EST (History)
15 users (show)

See Also:


Attachments
Patch for plugin "org.eclipse.search" (5.88 KB, patch)
2011-07-18 02:28 EDT, Marko Tomljenovic CLA
no flags Details | Diff
Workspace patch (GIT format) (6.75 KB, patch)
2011-07-20 05:23 EDT, Marko Tomljenovic CLA
daniel_megert: review-
Details | Diff
Updated picture for doc.user plugin (27.49 KB, image/png)
2011-07-20 05:23 EDT, Marko Tomljenovic CLA
no flags Details
Proposed solution for the bug (3.67 KB, patch)
2013-01-05 16:07 EST, Marco Descher CLA
daniel_megert: review-
Details | Diff
New Customize... dialog (34.55 KB, image/png)
2013-01-05 16:08 EST, Marco Descher CLA
no flags Details
Alternate solution with Radio selector (4.32 KB, patch)
2013-01-07 16:03 EST, Marco Descher CLA
daniel_megert: review-
Details | Diff
Search Customize Dialog with selection (35.94 KB, image/png)
2013-01-07 16:04 EST, Marco Descher CLA
no flags Details
Solution with Checkbox (and formatter) (23.37 KB, patch)
2013-02-28 04:14 EST, Marco Descher CLA
no flags Details | Diff
Formatting corrected version (5.87 KB, patch)
2013-02-28 07:16 EST, Marco Descher CLA
no flags Details | Diff
Reworked patch according to (5.66 KB, patch)
2013-03-01 10:26 EST, Marco Descher CLA
daniel_megert: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pradeep Kanwar CLA 2003-03-03 17:49:01 EST
AIM:
search for a text (say, 'supplierOID') in various source code files
Means:
use the search toolbar button ( torch )
action:
click on the torch icon
input the value 'supplierOID'
select the right tab , in our case the text
Problem:
Comment 1 Pradeep Kanwar CLA 2003-03-03 18:40:52 EST
Problem :
the most common action is to search for text in files under some directory ( 
like grep -i abc * ) but the default focus comes to 'Java Search'. There should 
be a way to set the default tab to 'File Search'.
Comment 2 Dani Megert CLA 2003-03-10 05:25:50 EST
>the most common action is to search for text in files under some directory
might be true for you but not for others ;-)

>There should be a way to set the default tab to 'File Search'.
The Search dialog no longer tries to be smart but opens with the last used
Search i.e. if you search for text once then it will come up with this page the
next time you open the Search dialog.
Comment 3 Pradeep Kanwar CLA 2003-03-10 21:28:32 EST
fine with me if that was the intended design. Thx anyway
Comment 4 Dani Megert CLA 2003-03-11 02:59:41 EST
We had lots of opinions about this and changed it several times. Which build are
you using? Wouldn't the 2.1 behavior be what you want (instead of setting your
default search page via preference you simply have to do one search to get this).
Comment 5 Dani Megert CLA 2003-03-11 11:56:46 EST
Sorry - I was wrong. We reverted the old behavior back.
I reopen the PR to consider for 2.2.

What you would like is a preference where you can specify the default page -
correct?
Comment 6 Pradeep Kanwar CLA 2003-03-11 13:12:02 EST
exactly. Like so many other things in eclipse a developer should be able to set 
a default preference on the 'favourite' search tab too. Hope it makes it in the 
2.2 ( btw i am on 2.1)
Comment 7 Dani Megert CLA 2003-03-11 13:32:17 EST
*** Bug 34680 has been marked as a duplicate of this bug. ***
Comment 8 Dani Megert CLA 2003-03-11 13:32:37 EST
see also  bug 34680
Comment 9 Dani Megert CLA 2003-03-12 07:18:24 EST
*** Bug 34799 has been marked as a duplicate of this bug. ***
Comment 10 Thomas M??der CLA 2003-12-05 04:48:50 EST
*** Bug 48103 has been marked as a duplicate of this bug. ***
Comment 11 Thomas M??der CLA 2004-02-17 09:08:52 EST
We should do something for 3.0. Any idea why we never went to the (simpler than
now) solution to just remember the last page?
Comment 12 Dani Megert CLA 2004-02-17 09:25:49 EST
- we wanted to be smarter than just remember the last one
- the last used page might no longer exist
Comment 13 Thomas M??der CLA 2004-02-17 10:22:21 EST
I think we should add the "last" page policy as an option. Marking as 3.0 candidate.
Comment 14 Thomas M??der CLA 2004-06-10 06:20:39 EDT
Not critical and too late now for 3.0
Comment 15 Markus Keller CLA 2004-06-10 06:29:44 EDT
Note that users can always assign another shortcut to 'Search > File Search' via
the 'Workbench > Keys' preference page. If you want, you can even assign Ctrl+H
to File Search.
Comment 16 Markus Keller CLA 2008-07-30 09:19:53 EDT
*** Bug 237160 has been marked as a duplicate of this bug. ***
Comment 17 Dani Megert CLA 2009-06-11 02:47:54 EDT
*** Bug 279741 has been marked as a duplicate of this bug. ***
Comment 18 Dani Megert CLA 2009-06-11 02:49:27 EDT
No plans to fix this but we should add a way to allow reopening the dialog with the previous settings, see see bug 199990.
Comment 19 Dani Megert CLA 2010-12-02 02:08:37 EST
*** Bug 331617 has been marked as a duplicate of this bug. ***
Comment 20 Dani Megert CLA 2011-07-11 05:03:08 EDT
*** Bug 351583 has been marked as a duplicate of this bug. ***
Comment 21 Dani Megert CLA 2011-07-11 05:26:47 EDT
*** Bug 351583 has been marked as a duplicate of this bug. ***
Comment 22 Dani Megert CLA 2011-07-11 05:28:54 EDT
Reopening as Marko offered to provide a patch.
Comment 23 Marko Tomljenovic CLA 2011-07-14 09:56:41 EDT
(In reply to comment #22)
> Reopening as Marko offered to provide a patch.

The place where the recommended editor is opened is in method SearchDialog.getPreferredPageIndex()
Comment 24 Marko Tomljenovic CLA 2011-07-18 02:28:53 EDT
Created attachment 199804 [details]
Patch for plugin "org.eclipse.search"
Comment 25 Marko Tomljenovic CLA 2011-07-18 02:36:41 EDT
I will provide a patch for the ...doc.user plugin too as soon as I can figure out how to create a patch of a changed png picture.
Does anybody know how to do that using the git command line?
Comment 26 Dani Megert CLA 2011-07-18 02:57:03 EDT
Marko, Search and Doc are currently live in CVS not Git. We're planning to move this summer. Could you attach a CVS workspace patch?

Images need to be attached separately (best in a ZIP file).
Comment 27 Marko Tomljenovic CLA 2011-07-18 03:00:23 EDT
(In reply to comment #26)
> Marko, Search and Doc are currently live in CVS not Git. We're planning to move
> this summer. Could you attach a CVS workspace patch?
> 
> Images need to be attached separately (best in a ZIP file).

:(

Our company firewall is completely blocking any CVS access so I have to make it at home. This will take some time ( a few days).
Comment 28 Marko Tomljenovic CLA 2011-07-20 05:23:03 EDT
Created attachment 199965 [details]
Workspace patch (GIT format)

This is a GIT created patch for my changes. I hope that applying it is ok for you. Otherwise I need to do all changes at home via the CVS access.

The new picture will be added seperately.
Comment 29 Marko Tomljenovic CLA 2011-07-20 05:23:58 EDT
Created attachment 199966 [details]
Updated picture for doc.user plugin
Comment 30 Dani Megert CLA 2011-07-20 05:27:22 EDT
I'll try when I find time (currently completely busy with Java 7).
Comment 31 Dani Megert CLA 2011-12-16 07:47:32 EST
Will review during M5.
Comment 32 Dani Megert CLA 2012-01-10 05:38:44 EST
Hi Marko,

I can apply the patch but it does not work i.e. it does not use the last used search page. Looking at the patch it's obvious: there is no code that stores the last used page ;-).


Some other comments:

- We already have a 'Customize...' button (and dialog) inside the search 
  dialog. This should be used to host the new option.

- The last used page should not be stored as a preference but as dialog setting.

- Test corner cases of your next patch:
  - plug-in that contributes last used page gets removed
  - last used search page gets disabled via 'Customize...'

- I don't like "Focus" in the option label (and the doc). How about
  "Show (or Activate) last used search page"
  "Show (or Activate) best fitting search page"

- The Javadoc of 'ISearchPageScoreComputer' and the 'extensions' attribute in 
  the 'org.eclipse.search.searchPages' extension point doc also needs to be 
  updated.

- Use the formatting already present in the files, e.g. we use compact 
  assignment.

- Add your credentials to each file, e.g.
Dani Megert <dani@eclipse.org> - this is a bug - http://bugs.eclipse.org/33710

- Update copyright date to 2012 in each file.
Comment 33 Dani Megert CLA 2012-01-24 03:44:45 EST
Marko, are you still interested in providing the patch?
Comment 34 Marko Tomljenovic CLA 2012-01-24 04:42:15 EST
I will not have time for the patch for the next few weeks. Need the time for renovating my house :)

Feel free to do the patch on your own.
Comment 35 Dani Megert CLA 2012-01-24 04:49:54 EST
(In reply to comment #34)
> I will not have time for the patch for the next few weeks. Need the time for
> renovating my house :)
> 
> Feel free to do the patch on your own.

I don't have time for this.
Comment 36 Dani Megert CLA 2012-11-30 07:42:54 EST
*** Bug 395453 has been marked as a duplicate of this bug. ***
Comment 37 Dani Megert CLA 2013-01-03 10:48:22 EST
*** Bug 397385 has been marked as a duplicate of this bug. ***
Comment 38 Marco Descher CLA 2013-01-03 16:40:19 EST
I am currently working on a follow-up patch so please consider my comments/questions:

> - We already have a 'Customize...' button (and dialog) inside the search 
>  dialog. This should be used to host the new option.
The Customize... is currently implemented as ListSelectionDialog, adding an option like
"Remember selected search tab" e.g. as Check Button at the end, requires substantial
modification to this Dialog. Is this definitely the way to go? What about simply adding
the Check Button "Remember selected search tab" directly to the Search Dialog?

>- The last used page should not be stored as a preference but as dialog setting.
Alright. #turnToPage() SearchPlugin.getDefault().getDialogSettings().put(PREVIOUS_SEARCH_PAGE, descriptor.getId());

>- Test corner cases of your next patch:
>  - plug-in that contributes last used page gets removed
>  - last used search page gets disabled via 'Customize...'
Will consider this eventually

>- I don't like "Focus" in the option label (and the doc). How about
>  "Show (or Activate) last used search page"
>  "Show (or Activate) best fitting search page"
Will not exist if option is to be embedded in "Customize..."

>- The Javadoc of 'ISearchPageScoreComputer' and the 'extensions' attribute in 
>  the 'org.eclipse.search.searchPages' extension point doc also needs to be 
>  updated.
Alright
Comment 39 Marco Descher CLA 2013-01-05 16:07:13 EST
Created attachment 225249 [details]
Proposed solution for the bug

I implemented a new patch for this problem, considering the given comments.

>- We already have a 'Customize...' button (and dialog) inside the search 
>  dialog. This should be used to host the new option.
Done. Screenshot to follow

>- The last used page should not be stored as a preference but as dialog setting.
Done

>- Test corner cases of your next patch:
>  - plug-in that contributes last used page gets removed
Falls back to default search page. (Tried using invalid descriptor string)
>  - last used search page gets disabled via 'Customize...'
Same.

>- I don't like "Focus" in the option label (and the doc). How about
>  "Show (or Activate) last used search page"
>  "Show (or Activate) best fitting search page"
Is now "Remember selected search tab"

>- The Javadoc of 'ISearchPageScoreComputer' and the 'extensions' attribute in 
>  the 'org.eclipse.search.searchPages' extension point doc also needs to be 
>  updated.
I am not sure what the wanted behavior is, so the current implementation disregards any
intelligent selection and sets the last used. If the behaviour should consider a "last selected"
per intelligent selection the implementation has to be made entirely different than now.

Other points:

Currently after disabling the feature the set last tab is not deleted, so if the feature
is re-enabled the lastly selected tab is re-opened. DialogSettings does not support the removal
of entries, this is already documented in Bug 92518.
Comment 40 Marco Descher CLA 2013-01-05 16:08:35 EST
Created attachment 225250 [details]
New Customize... dialog
Comment 41 Markus Keller CLA 2013-01-07 11:33:38 EST
> "Remember selected search tab"

The problem with this label is that the alternative is not clear. This solution makes clear that the option only affects the 'Search...' command and describes both alternatives:

'Search...' opens:
o Last used tab
o Best tab for selection
Comment 42 Marco Descher CLA 2013-01-07 16:03:15 EST
Created attachment 225310 [details]
Alternate solution with Radio selector

I see, do you think about something like a selector in the customize? The enclosed patch realizes it using a Radio button, certainly there could also be combo etc. I'll finish that out as soon as the "specification" is set :)
Comment 43 Marco Descher CLA 2013-01-07 16:04:05 EST
Created attachment 225311 [details]
Search Customize Dialog with selection

The Customize.. dialog with resp. radio selection
Comment 44 Marco Descher CLA 2013-02-21 01:56:11 EST
Anybody interested in giving a comment to the proposed patch?
Comment 45 Dani Megert CLA 2013-02-27 06:47:04 EST
Comment on attachment 225249 [details]
Proposed solution for the bug

This patch does not seem to work and it does an unwanted page switch after confirming the dialog:
1. start new workspace
2. open Search
3. switch to 'Java Search'
4. change the setting
==> page flips back to 'File Search', expected: stays on the current page
5. close the dialog
6. open it again
BUG: opens on 'File Search'

I don't like the option name. Maybe better:
&Remember last used page
(The '&' denotes the mnemonic which missing in your patch).
Comment 46 Dani Megert CLA 2013-02-27 06:48:15 EST
Comment on attachment 225310 [details]
Alternate solution with Radio selector

This patch works better than the previous one, but using radio buttons for this on/off option is not nice.
Comment 47 Marco Descher CLA 2013-02-28 03:31:47 EST
The "Remember last used page" overrides the selection in any case, so the user should know about that behaviour, shouldn't she? 

Currently there is some kind of intelligent selection depending on the editor opened, this would be completely overriden, hence the intent to provide a radio button to explicitely show this to the user.

A on/off option only would not transfer the meaning of the option correctly, as one may think that it sets the "remember last page" per intelligent selection one had. E.g. I called search from within a Java editor, and now everytime I call it from a Java editor leads to the last selected search page I had in this context.
Comment 48 Dani Megert CLA 2013-02-28 03:39:15 EST
(In reply to comment #47)
> The "Remember last used page" overrides the selection in any case, so the
> user should know about that behaviour, shouldn't she? 

Sorry, I'm not sure what you try to say/explain here.


> Currently there is some kind of intelligent selection depending on the
> editor opened, this would be completely overriden, hence the intent to
> provide a radio button to explicitely show this to the user.

Having "Remember last used page" checked explains that too.
Comment 49 Marco Descher CLA 2013-02-28 04:14:05 EST
Created attachment 227716 [details]
Solution with Checkbox (and formatter)

Please have a look at the enclosed patch which solves the problem using Check. I have been trying to get the formatting right to remove all the noise. 

What formatting style is used in this class? I am using the current one but this does not work out. It should, however, be possible to grasp the main changes quite fast.
Comment 50 Dani Megert CLA 2013-02-28 06:43:15 EST
Comment on attachment 227716 [details]
Solution with Checkbox (and formatter)

The functionality is good now and works as expected!

In order to review (and later commit), the patch I need one that has only changes where needed and which does not reformat existing untouched code.

Please also update the copyright notice (and date) in all the files that you touch.


> I have been trying to get the formatting right to remove all the noise. 
Actually, doing no formatting at all on the existing code and just format the code that you add (e.g. using a Save Action that only formats the changed lines).

> What formatting style is used in this class?
Normally, we use the profile that's attached to the project, but we never re-formatted all the code at the time when we settled on that profile.
Comment 51 Marco Descher CLA 2013-02-28 07:16:48 EST
Created attachment 227721 [details]
Formatting corrected version

There you go. Enclosed, the corrected version according to your rules.
Comment 52 Dani Megert CLA 2013-03-01 03:54:10 EST
Comment on attachment 227721 [details]
Formatting corrected version

Thanks Marco. I reviewed the patch and it is good except for some minor details:

- defaultDialogSettings has several issues:
  - field names are prefixed with 'f'
  - we must not write into the root of that store, but create/use a section,
    see DialogSettings.getOrCreateSection(IDialogSettings, String)
- improve the dialog setting constants (see TextSearchPage for an example)
- use speaking names for variables (e.g. 'b' is not so good)
- replace nested if with one if and a &&
- rename the NLS key to SearchPageSelectionDialog_rememberLastUsedPage_message

After that polish pass, the patch is good to go!
Comment 53 Marco Descher CLA 2013-03-01 10:26:07 EST
Created attachment 227800 [details]
Reworked patch according to

Hy Dani, thanks for your feedback, enclosed the reworked patch according to your comments.
Comment 54 Dani Megert CLA 2013-03-11 10:32:51 EDT
(In reply to comment #53)
> Created attachment 227800 [details] [diff]
> Reworked patch according to
> 
> Hy Dani, thanks for your feedback, enclosed the reworked patch according to
> your comments.

I've committed your patch with http://git.eclipse.org/c/platform/eclipse.platform.text.git/commit/?id=b93444c2bf7a4607e4741b8aa0a51ce82d28a357


After that I made some minor tweaks:

- used better names for 'ret' and 'fDefaultDialogSettings'
- fixed some wrong indentations
- also store the last used page if the user never manually switched to another
  page
- added bug summary to copyright (forgot to mention this in the previous review)

Fixed with http://git.eclipse.org/c/platform/eclipse.platform.text.git/commit/?id=97b1cf4b6990936dca33ed932af778c661f5fd04
Comment 55 Markus Keller CLA 2013-03-12 07:31:00 EDT
The setting must only be saved when user closes the Customize dialog with OK.

Fixed with http://git.eclipse.org/c/platform/eclipse.platform.text.git/commit/?id=8eb5d915d6bdb101cbb3597425c9892ee08f3fab
Comment 56 Dani Megert CLA 2013-03-13 05:02:38 EDT
Verified in I20130312-2000.