Bug 86973 - [Dialogs][IDE] Open Resource dialog should accept pattern for matching folder path
Summary: [Dialogs][IDE] Open Resource dialog should accept pattern for matching folder...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0.1   Edit
Hardware: PC Windows XP
: P2 enhancement with 2 votes (vote)
Target Milestone: 3.6 M7   Edit
Assignee: Markus Keller CLA
QA Contact: Susan McCourt CLA
URL:
Whiteboard:
Keywords: polish
: 210761 239588 290121 295327 (view as bug list)
Depends on:
Blocks: 193911
  Show dependency tree
 
Reported: 2005-03-02 04:21 EST by Markus Keller CLA
Modified: 2010-04-26 10:18 EDT (History)
13 users (show)

See Also:


Attachments
First patch for open resource using Paths (9.28 KB, patch)
2008-05-19 07:00 EDT, James Blackburn CLA
no flags Details | Diff
Patch 2 (8.97 KB, patch)
2008-05-19 09:10 EDT, James Blackburn CLA
no flags Details | Diff
patch 3 (10.23 KB, patch)
2009-11-03 13:17 EST, James Blackburn CLA
markus.kell.r: iplog+
Details | Diff
Patch 4 (11.64 KB, patch)
2010-03-22 18:58 EDT, Markus Keller CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2005-03-02 04:21:04 EST
The Open Resource dialog currently only accepts patterns for a file name (e.g.
"plugin.*"). It should also match patterns for a folder path.

E.g. I would expect that the pattern "*jdt.ui*/plugin.xml" filters the folders
list to only show folders whose name matches the sub-pattern "*jdt.ui*", i.e.
"org.eclipse.jdt.ui", "org.eclipse.jdt.ui.tests", etc.
Comment 1 James Blackburn CLA 2008-05-09 05:28:38 EDT
This is a very desirable feature.

Might I suggest that instead of path/to*Filename as a pattern, spaces are allowed to separate independent expressions.

For example, in the CDT world where you want to open a Makefile, a user might:
1) ctrl-shift-R
2) Type Makefile
3) See many many entries, so type space and start typing part of the path.

The dialog would then show the files matching the intersection of the two expressions (+any files/paths which match the full expression including the space...)
Comment 2 James Blackburn CLA 2008-05-19 07:00:15 EDT
Created attachment 100887 [details]
First patch for open resource using Paths

Patch to add support for opening resources using Paths.

This patch adds a couple additional features:
1) Relative paths are treated as relative to the currently open editor's container 
   or current selection if there isn't a currently open editor
2) After sorting alphabetically, I sort files within the current container before other files in the Workspace.

It turns out, from my comment #2, that a search engine style with multiple keywords would require further changes...

Any feedback would be much appreciated!

James
Comment 3 James Blackburn CLA 2008-05-19 09:10:54 EDT
Created attachment 100900 [details]
Patch 2

Previous patch included a change to an unrelated file...
This patch is against version 1.19 in the Eclipse CVS (as 1.19 is not quite as compatible with 3.3.x)
Comment 4 Philipe Mulet CLA 2008-05-23 04:29:59 EDT
Please adjust the target milestone, so it does not point at a closed milestone in the past.
Comment 5 Markus Keller CLA 2008-05-30 04:18:26 EDT
(In reply to comment #4)
I don't think Krzysztof is still working on this. Assigning back to inbox.
Comment 6 Szymon Brandys CLA 2008-05-30 04:30:58 EDT
Krzysztof left the team some time ago. I'm removing the target milestone.
Comment 7 James Blackburn CLA 2008-05-30 04:40:35 EDT
This is  a much requested feature -- especially from guys coming from emacs...  It would be good if this patch could be picked up / commented on by one of you committers.
Comment 8 Szymon Brandys CLA 2008-05-30 07:06:14 EDT
Markus, I left the assignee on purpose. I'm waiting for the decision who in UI will take over this stuff. When I have it, I will move all Krzysztof's bugs to the person and I won't bother the UI triage monkey.
Comment 9 Szymon Brandys CLA 2008-05-30 11:33:07 EDT
Reassigning to Susan.
Comment 10 James Blackburn CLA 2008-09-24 11:38:58 EDT
Hi Susan, Szymon et al.,

Is it possible to get some feedback on this patch.  This is a much wanted feature for people coming from emacs, and we've been using this patch successfully here for some time... It would be really great for this to get into 3.5

Cheers,

James
Comment 11 Susan McCourt CLA 2008-09-24 12:03:47 EDT
Hi, James.  Thanks for the patch.

This bug got reassigned as we were wrapping up 3.4, hence it fell through the cracks for a little while (longer).  I don't have a lot of time for platform UI bugs during 3.5, but I am trying to review patches for a day or two during M3 and M4.  I'll mark this M4.

In the meantime, I'd like to make sure that the patch is consistent with the original suggestion, or at least that we agree on the requirements.

>It turns out, from my comment #2, that a search engine style with multiple
>keywords would require further changes...

can you confirm that your patch implements the scheme Markus originally suggested (being able to supply patterns in a "folder path/file" format?

>This patch adds a couple additional features:
>1) Relative paths are treated as relative to the currently open editor's
>container 
>   or current selection if there isn't a currently open editor
>2) After sorting alphabetically, I sort files within the current container
>before other files in the Workspace.

I'd have to try this out to see how it plays.  #2 sounds reasonable, I'm not sure how #1 will play, if it will be confusing or just do the right thing.  Any thoughts, Markus?





Comment 12 James Blackburn CLA 2008-09-24 12:21:52 EDT
Hi Susan, thanks for the prompt reply.

(In reply to comment #11)
> >It turns out, from my comment #2, that a search engine style with multiple
> >keywords would require further changes...
> 
> can you confirm that your patch implements the scheme Markus originally
> suggested (being able to supply patterns in a "folder path/file" format?

Indeed.  You can type things like:
/project_name/some_folder/*/foo.java
or
*/some_folder/*/foo.java
or just
foo.java
as before.

Basically "/" is the workspace root which allows you to restrict to a certain project if you wish. Alternatively you can filter on any part of the path.

> I'd have to try this out to see how it plays.  #2 sounds reasonable, I'm not
> sure how #1 will play, if it will be confusing or just do the right thing.  Any
> thoughts, Markus?

The reason for #1 is that in the C world where nearly every direcoty has a file called "Makefile". When the user wants to editor a Makefile, they want the one that corresponds to the current editor which is usually the one in the current directory. 
In emacs (/other text editors) many users are also used to opening a file 'relative' to the currently open file. i.e. they do ctrl-shift-r and type ../some_other_file.

Have a go with the patch and see what you think, I guess.  Basically it has the same behaviour as open-resource does currently it simply now considers a path as well if the user desires :). 

BTW I believe BUG239588 is a dup of this -- though pwebster was 'excluded' from the list of notifiees when I submitted the comment to that effect.

If you have any issues with the patch i'm quite happy to address them!
Comment 13 Paul Webster CLA 2008-09-25 10:17:47 EDT
*** Bug 239588 has been marked as a duplicate of this bug. ***
Comment 14 Markus Keller CLA 2008-09-28 08:43:53 EDT
(In reply to comment #11)
> I'd have to try this out to see how it plays.  #2 sounds reasonable, I'm not
> sure how #1 will play, if it will be confusing or just do the right thing.  Any
> thoughts, Markus?

Both additional features from comment 2 sound a bit scary at first, since the dependency on the editor input might no be obvious to the user. But the "Makefile" example sounds compelling, so I would give it a try. Note that "plugin.xml" file in plug-in development is a similar case. You often want to open the manifest for the editor input's enclosing project.

Since this patch adds nontrivial functionality to the Open Resource dialog, you should also write a help page and set the dialog's help context id, such that users can quickly read more about how the dialog works (cf. the Open Type dialog).

I would also adapt the first label in the dialog, e.g. to 
"Enter prefix or pattern for resource name or path (wildcards: ?, *):".
Comment 15 Dani Megert CLA 2009-01-30 03:31:50 EST
Moving target as M4 has shipped.
Comment 16 Susan McCourt CLA 2009-01-30 11:49:47 EST
marking UI (so it shows up in my lists)
Comment 17 Susan McCourt CLA 2009-02-19 18:23:07 EST
Dani, do you have time to look at this?
I think you are in a better position to evaluate this, and I think you own open resource now?
Comment 18 Dani Megert CLA 2009-02-20 02:29:49 EST
>Dani, do you have time to look at this?
Sorry no time. The question is also whether we make the suggested changes/additions mentioned in comment 14 or whether we wait for a new patch from James. 
Comment 19 James Blackburn CLA 2009-02-20 03:16:09 EST
(In reply to comment #18)
> >Dani, do you have time to look at this?
> Sorry no time. The question is also whether we make the suggested
> changes/additions mentioned in comment 14 or whether we wait for a new patch
> from James. 

Woops, this slipped.  I'll try to make some time this weekend.
Comment 20 Susan McCourt CLA 2009-02-25 14:45:20 EST
removing M6 milestone, there's no way I can shift attention to this right now (sorry).  If there is someone else who cares enough to shepherd this into the release, please take this bug.
Comment 21 Markus Keller CLA 2009-02-26 05:04:38 EST
James, if you add another patch, please make the fields you added private (rather than protected). And you cannot remove the old constructor of ResourceFilter, since it is API.

The way you store the filter in createFilter() is problematic. It breaks as soon as subclasses override the method. You should probably add a protected FilteredItemsSelectionDialog#getCurrentFilter() method and use that (give little guarantees in the API and check for null when accessing).

Check that Navigate > Go To > Resource... works in the Package Explorer.
Comment 22 Susan McCourt CLA 2009-07-09 15:55:54 EDT
As per http://wiki.eclipse.org/Platform_UI/Bug_Triage_Change_2009
Comment 23 Szymon Brandys CLA 2009-09-22 09:04:20 EDT
*** Bug 290121 has been marked as a duplicate of this bug. ***
Comment 24 James Blackburn CLA 2009-11-03 13:17:40 EST
Created attachment 151223 [details]
patch 3

Patch update for HEAD.

The previous patch only extended FilteredSelectionDialog to allow matching paths. This patch adds 'distance' to the sort criteria. Distance is defined as the count of the number of directories you would need to change (using cd for example) where you're only allowed to change one directory at a time.  Therefore ctrl-shift-R: plugin.xml should give you the plugin.xml that's nearest to your current selection i.e the one in the current project.

It's important to note that the file name sort *still* dominates. i.e. this distance metric is only used where file names are identical.

The result should be that more relevant entries are near the top rather than the currently arbitrary shortest fullPaths first approach. 

Review / feedback / committing  would be appreciated :)

Note there's already an existing bug 193911 requesting help for the Open Resource dialog. 

(In reply to comment #21)
> James, if you add another patch, please make the fields you added private
> (rather than protected). And you cannot remove the old constructor of
> ResourceFilter, since it is API.

The attached patch should be API clean (I've got API tooling enabled).

> Check that Navigate > Go To > Resource... works in the Package Explorer.

This should now work.
Comment 25 Paul Webster CLA 2009-11-17 08:08:50 EST
*** Bug 295327 has been marked as a duplicate of this bug. ***
Comment 26 Markus Keller CLA 2009-11-17 09:24:42 EST
*** Bug 210761 has been marked as a duplicate of this bug. ***
Comment 27 Aleksander Adamowski CLA 2009-12-10 10:00:29 EST
So are there any obstacles to committing this patch in?
Comment 28 Susan McCourt CLA 2009-12-15 14:40:22 EST
(In reply to comment #27)
> So are there any obstacles to committing this patch in?
The obstacle at this point is simply making time to review...I'll mark this M6 to keep it on the radar.  (My M5 is already overcommitted).

Markus, since you are a committer now, if you want to take this bug, I would have no objections.
Comment 29 Markus Keller CLA 2009-12-16 05:08:39 EST
OK, I'll take this.

(In reply to comment #14)
> Since this patch adds nontrivial functionality to the Open Resource dialog, you
> should also write a help page and set the dialog's help context id, such that
> users can quickly read more about how the dialog works (cf. the Open Type
> dialog).

Any help for this would be appreciated (bug 193911). I don't want to ship this change without proper doc.
Comment 30 Susan McCourt CLA 2009-12-16 11:31:41 EST
(In reply to comment #29)
> OK, I'll take this.

thanks, Markus.

> 
> (In reply to comment #14)
> > Since this patch adds nontrivial functionality to the Open Resource dialog, you
> > should also write a help page and set the dialog's help context id, such that
> > users can quickly read more about how the dialog works (cf. the Open Type
> > dialog).
> 
> Any help for this would be appreciated (bug 193911). I don't want to ship this
> change without proper doc.

I took this bug for myself for 3.5M6.  Seems like a fair swap!
Comment 31 Susan McCourt CLA 2009-12-16 11:33:00 EST
Markus, I assumed you are ok if the doc lags behind a bit?  I could try to get skeletal context help in for M5 and flesh it out later?
Comment 32 Markus Keller CLA 2010-01-25 07:06:38 EST
(In reply to comment #31)
> Markus, I assumed you are ok if the doc lags behind a bit?  I could try to get
> skeletal context help in for M5 and flesh it out later?

Sorry, I didn't get to this in time and don't want to risk stability now. I'll release it in M6 and add the docs (which should take less time if I do it right after the code review).
Comment 33 Markus Keller CLA 2010-03-08 09:06:30 EST
I've still too much on my plate, have to move this to M7. I verified that we don't need any of the APIs the patch adds.
Comment 34 Jacob Straszynski CLA 2010-03-08 21:42:41 EST
Just throwing my voice in the chorus here if it makes a difference. As a Django/Python developer I have about 10 files named "models.py" and I would love to able to something like "*db/*models*.

CTRL+Shift+R is a great shortcut, but it's somewhat less effective when your filenames don't contain module/app prefixes.
Comment 35 Martin Oberhuber CLA 2010-03-12 06:37:53 EST
Interesting idea.

Isn't the "**" commonly used for matching multiple path segments?
Comment 36 James Blackburn CLA 2010-03-17 13:44:43 EDT
Now that M6 is out the door, it would be great if you could review this for commit Markus.  It'd be great to get this into Helios!
Comment 37 Markus Keller CLA 2010-03-22 18:58:47 EDT
Created attachment 162730 [details]
Patch 4

Released to HEAD with a few changes:

- made new members private
- replaced calls to IPath#toOSString() with IPath#toString(). The Open Resource dialog deals with workspace-relative paths, and for those, Eclipse uses '/' as separator on all platforms.
- made context more predictable by only getting it from the active part (if an editor has focus, take the editor input, otherwise take the selected element if there is one)
- fixed problem with initialization of resourceRelativePattern in the ResourceFilter: IPath#append(String) only works fine if the argument is really a valid path. To avoid problems with invalid paths (e.g. path "abc:" on Windows), I now append the pattern manually (unless it starts with a '/').
- fixed ResourceFilter#pathDistance(IContainer): It needs to return a big distance when no segments match (otherwise the sum of their segment counts is used for sorting, and that's wrong)
- reverted the change in ResourceFilter#isConsistentItem(Object). I don't see why that should be necessary, and it looked wrong.
- moved pathDistance(..) into the Comparator
Comment 38 Markus Keller CLA 2010-03-22 18:59:46 EDT
Fixed.
Comment 39 Markus Keller CLA 2010-03-23 06:37:51 EDT
I've released an additional fix for I20100323-0800 to avoid an NPE when the history cache contains files with the same name.
Comment 40 James Blackburn CLA 2010-03-23 08:04:03 EDT
(In reply to comment #37)
> Created an attachment (id=162730) [details]
> Patch 4

Thanks Markus!! The changes all look good to me.
Comment 41 Markus Keller CLA 2010-04-11 20:19:00 EDT
Patterns that start with "*" did not only match file names, but also folder paths. I found that confusing, and it's also a performance hit for simple file name patterns.

For I20100406, I've released a follow-up fix that separates folder path and file name patterns at the last '/', and that improves performance in other places by avoiding resource.getFullPath().toString() as much as possible.
Comment 42 James Blackburn CLA 2010-04-15 10:46:45 EDT
One of the things that used to work, but doesn't with the patch on HEAD is the ability to open files relative to that in your current editor.

This was the primary driver for me implementing the feature, users, editing a file do:
  ctrl-shift-r
  ./
and open resource shows the set of files in the current directory and below. Currently it's empty.
Comment 43 Markus Keller CLA 2010-04-22 16:49:21 EDT
(In reply to comment #42)
> Currently it's empty.
I've fixed the support for relative paths (starting with ./ or ../) in HEAD. It already worked for ./* or ./xxx but the rest was broken.

> [..] the current directory and below.

The "and below" part is problematic. We need to offer a way to match only in the current directory, and ./xxx does that. In 3.7, we could look into Ant-like patterns, where ** could expand to zero or more directories.
Comment 44 Markus Keller CLA 2010-04-22 16:53:29 EDT
> The "and below" part is problematic.

I know it's a hack, but you can use "../*/abc" as a workaround to match files starting with "abc" in the current folder or below ("*" matches 1 or more directories, so "./*/abc" would not match in the current directory).
Comment 45 James Blackburn CLA 2010-04-22 17:16:43 EDT
Excellent, thanks markus! 
Will have a look tomorrow, but that certainly fulfils the main use-case we have of opening the Makefile in the same directory as the source.
Comment 46 Dani Megert CLA 2010-04-26 10:18:44 EDT
Verified in I20100425-2000 on Windows 7.

While testing I really missed the feature that shows the matching characters (bug 264840).