Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 244353

Summary: java class hyperlink detection should provide multiple options when multiple results are found for a class name
Product: z_Archived Reporter: David Green <greensopinion>
Component: MylynAssignee: Jingwen 'Owen' Ou <jingweno>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jingweno, steffen.pingel
Version: dev   
Target Milestone: 3.1   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 244380    
Bug Blocks: 239087    
Attachments:
Description Flags
a patch pops up a dialog for multiple hyperlinks
none
mylyn/context/zip
none
screenshot of the popup dialog
none
a patch disables converting move to copy in TaskEdtiorDropTarget
none
a patch that uses Java Open Type dialog whne clicking the hyperlink
none
mylyn/context/zip none

Description David Green CLA 2008-08-15 20:03:32 EDT
hyperlink detection creates one hyperlink if the 'java class' prefix is found preceding a word. (eg: java class Object)
The word is passed to the Java search engine to find matches for the given class name.  If multiple search results are found the hyperlink should allow the user to choose the desired one rather than arbitrarily choosing the first one as it does now.

this is related to bug 244352 and bug 239087
Comment 1 Jingwen 'Owen' Ou CLA 2008-08-16 01:32:26 EDT
Does a multiple hyperlinks make sense for this, I mean the new 3.4 feature?
Comment 2 Steffen Pingel CLA 2008-08-16 02:13:52 EDT
Yes, I think that would be a good solution. Mylyn currently supports Eclipse 3.3 as well as 3.4 though so this would have to be implemented through reflection or by back-porting the 3.4 hyperlink presenter.
Comment 3 David Green CLA 2008-08-16 12:55:36 EDT
The downside of using multiple hyperlinks is that the Java search has to be done in the hyperlink detector rather than in the hyperlink -- which means that the penalty is paid even if the user doesn't click on the link.  This could be a major problem for editors that have dozens of comments with class references.  I like the idea of it working more like the CTRL+SHIFT+T (Open Type) functionality of eclipse, where the search is done at the time of clicking as it does now.
Comment 4 Jingwen 'Owen' Ou CLA 2008-08-16 16:54:42 EDT
Another compromise that I can come up with its to drop the absolute path of a IJavaElement, e.g. org.foo.bar.ITask. 

(In reply to comment #3)
> which means that the
> penalty is paid even if the user doesn't click on the link.  This could be a
> major problem for editors that have dozens of comments with class references.

I think we are already searching the Java class to minimize false positive, e.g. JavaResourceHyperlinkExtension.isResourceExists(..). Maybe its not a good idea to do that, any comments to improve the performance as well as the flexibility of the extension point, e.g. bug 240423?
Comment 5 Steffen Pingel CLA 2008-08-16 17:21:13 EDT
That's a very good point David. I agree that delaying the processing until after the link is clicked is better. As Owen points out JavaResourceHyperlinkExtension.isResourceExists() already does some processing though. Owen, does it make sense to not do that in the case of Java where we don't know how long it will take?

To present multiple matches we could popup a menu in case there are multiple matches similar to the 3.4 hyperlink presenter but I am not sure how well the user interaction would work if searching for the class takes a while.

(In reply to comment #4)
> Another compromise that I can come up with its to drop the absolute path of a
> IJavaElement, e.g. org.foo.bar.ITask.

I do like the short form. I think I would even prefer if it matched on just "class" or "java". Would it be possible to drop the full qualified name when a modifier is pressed, i.e. it's a copy rather than a move operation?
Comment 6 Jingwen 'Owen' Ou CLA 2008-08-17 20:45:04 EDT
Created attachment 110182 [details]
a patch pops up a dialog for multiple hyperlinks
Comment 7 Jingwen 'Owen' Ou CLA 2008-08-17 20:45:11 EDT
Created attachment 110183 [details]
mylyn/context/zip
Comment 8 Jingwen 'Owen' Ou CLA 2008-08-17 20:52:26 EDT
Created attachment 110184 [details]
screenshot of the popup dialog
Comment 9 Jingwen 'Owen' Ou CLA 2008-08-17 21:04:00 EDT
(In reply to comment #5)
> Owen, does it make sense to not do that in the case of Java where we
> don't know how long it will take?

I added a patch in bug 244380 to fix it.

> To present multiple matches we could popup a menu in case there are multiple
> matches similar to the 3.4 hyperlink presenter but I am not sure how well the
> user interaction would work if searching for the class takes a while.

I used a popup dialog in my last patch. I like it! You can try if it fits.

> I do like the short form. I think I would even prefer if it matched on just
> "class" or "java". Would it be possible to drop the full qualified name when a
> modifier is pressed, i.e. it's a copy rather than a move operation?

I am not sure I totally understand this point. Its possible to drop the full qualified name to the task editor.
Comment 10 Steffen Pingel CLA 2008-08-17 22:57:28 EDT
> > I do like the short form. I think I would even prefer if it matched on just
> > "class" or "java". Would it be possible to drop the full qualified name when a
> > modifier is pressed, i.e. it's a copy rather than a move operation?
> 
> I am not sure I totally understand this point. Its possible to drop the full
> qualified name to the task editor.

I was suggesting to either paste the short name or the full qualified name depending on the dnd operation. It seems that the package explorer deletes the source file if I a use move operations (rather than copy) so it might be best to only support copy.
Comment 11 Jingwen 'Owen' Ou CLA 2008-08-17 23:15:21 EDT
> I was suggesting to either paste the short name or the full qualified name
> depending on the dnd operation. It seems that the package explorer deletes the
> source file if I a use move operations (rather than copy) so it might be best to
> only support copy.

It won't. Please take a look at TaskEditorDropTarget.dragEnter(..). It will convert all move operations to copy. 
Comment 12 Steffen Pingel CLA 2008-08-18 00:03:32 EDT
Maybe it's a Linux thing. If I press shift when dropping a file from the package explorer it's deleted from the local filesystem.
Comment 13 Jingwen 'Owen' Ou CLA 2008-08-18 00:19:59 EDT
Created attachment 110190 [details]
a patch disables converting move to copy in TaskEdtiorDropTarget

ok, lets disalbe it for now. Actaully it works ok on my machine (window xp)
Comment 14 Steffen Pingel CLA 2008-08-21 01:50:36 EDT
I have applied the first patch. Thanks! I have changed the drop target implementation to always use copy. This works on Linux as well.

Owen, as per conference call can you check if it is possible to improve the implementation by using the Java Open Type dialog?
Comment 15 Jingwen 'Owen' Ou CLA 2008-08-24 22:52:59 EDT
Created attachment 110763 [details]
a patch that uses Java Open Type dialog whne clicking the hyperlink

I am not sure whether its a good idea to use open type dialog. But it does have many false positives.
Comment 16 Jingwen 'Owen' Ou CLA 2008-08-24 22:56:25 EDT
when I clicked "java class HTML", it displays HTMLParagraphElement as the first element, and other elements starting with HTML* fill the dialog.
Comment 17 Steffen Pingel CLA 2008-09-20 02:45:46 EDT
Excellent! Patch applied. The dialog does indeed show all prefix matches which may include unwanted classes. Given that the perfect matches are on top of the list I think the benefits of the richer dialog outweigh the disadvantages.
Comment 18 Steffen Pingel CLA 2008-09-20 03:11:13 EDT
Created attachment 113061 [details]
mylyn/context/zip