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

Bug 182839

Summary: [api] Provide multiple task hyperlink extraction from text
Product: z_Archived Reporter: Eugene Kuleshov <ekuleshov>
Component: MylynAssignee: Steffen Pingel <steffen.pingel>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P4    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:

Description Eugene Kuleshov CLA 2007-04-17 19:03:18 EDT
I found something strange in Bugzilla and Trac hyperlink detectors (strangely, detector for JIRA that I wrote don't have that). So, BugzillaRepositoryUi.findHyperlinks() have check like this:

       Matcher m = PATTERN.matcher(text);
       while (m.find()) {
           if (lineOffset >= m.start() && lineOffset <= m.end()) {
               IHyperlink link = extractHyperlink(repository, regionOffset, m);
               if (link != null)
                   hyperlinksFound.add(link);
           }
       }

So, this detection is only working if you point lineOffset inside that potential hyperlink. That is fine if it is called from the mouse events, but it does not work if I need to fetch all hyperlinks from any given text.

If we just get rid of the lineOffset condition (note that Platform's urlhyperlinkdetector don't do such range check), then hyperlinks will behave weird in the task editor (the whole line is hyperlinked). So, there is probably something wrong in task editor too.
Comment 1 Robert Elves CLA 2007-04-20 23:45:36 EDT
Currently only one hyperlink can be displayed thus only one hyperlink must be returned, the 'one' we want. Thus the lineOffset constraint in this method.  We could add an additional method that just returns all hyperlinks.
Comment 2 Eugene Kuleshov CLA 2007-04-21 10:35:53 EDT
IHyperlinkDetector.detectHyperlinks() have canShowMultipleHyperlinks parameter, which is currently not respected by task hyperlink detector. Though I am still puzzled by JIRA's detector is working without this range check and multiple JIRA links (even on the same line) are working just fine.
Comment 3 Robert Elves CLA 2007-04-21 12:06:08 EDT
I had a look at the JIRA hyperlink detector and it is using the lineOffset, albeit in a slightly different manner, to achieve the same result: detection of a single hyperlink located under the cursor, which is what we need for hyperlink detection in editors/viewers.  

The canShowMultipleHyperlinks parameter is ignored because the platform's DefaultHyperlinkPresenter isn't capable of displaying multiple hyperlinks for a given region. However, decoration of all hyperlinks in the body of the text is supported by the DefaultDamagerRepairer via RepositoryViewerConfig.
Comment 4 Robert Elves CLA 2007-05-07 19:19:52 EDT
So Eugene, if you want to let me know what requirements you have here we can add the api.
Comment 5 Robert Elves CLA 2008-04-06 13:58:14 EDT
With 3.4M6 we got multiple hyperlink support, Eugene, do you want to look into what the implications are for 3.0?
Comment 6 Eugene Kuleshov CLA 2008-04-07 12:41:17 EDT
(In reply to comment #5)
> With 3.4M6 we got multiple hyperlink support, Eugene, do you want to look into
> what the implications are for 3.0?

Sorry, Rob, I am not sure when I'll be moving to 3.4m6. Probably not until after j1.
Comment 7 Robert Elves CLA 2008-04-07 20:23:42 EDT
No worries. I'll push post 3.0 here and we can revisit then.
Comment 8 Steffen Pingel CLA 2008-09-24 01:28:34 EDT

*** This bug has been marked as a duplicate of bug 244442 ***