Bug 181747 - Hyperlink with macro detector
Summary: Hyperlink with macro detector
Status: RESOLVED FIXED
Alias: None
Product: Linux Tools
Classification: Tools
Component: RPM (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: RPM Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-04-10 08:31 EDT by Alphonse Van Assche CLA
Modified: 2009-01-23 10:25 EST (History)
1 user (show)

See Also:


Attachments
URLHyperlinkWithMacroDetector (6.63 KB, patch)
2007-04-10 08:32 EDT, Alphonse Van Assche CLA
overholt: iplog+
Details | Diff
new URLHyperlinkWithMacroDetector - extend rather than re-implement (2.93 KB, patch)
2007-04-13 10:24 EDT, Andrew Overholt CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alphonse Van Assche CLA 2007-04-10 08:31:39 EDT
Add a hyperlink detector that resolve macros, have just add to the JFace URLHyperlinkDetector a method that resolve macro before returning the IHyperlink to the workbench.

2007-04-10  Alphonse Van Assche  <alcapcom@gmail.com>

	* src/org/eclipse/linuxtools/rpm/ui/editor/URLHyperlinkWithMacroDetector.java:
        New new class to resolve macro in URL. 
	(detectHyperlinks): New method.
	(URLHyperlinkWithMacroDetector): Likewise.
	(resolveDefinesInURL): Likewise.
	* src/org/eclipse/linuxtools/rpm/ui/editor/SpecfileConfiguration.java: 
	(getHyperlinkDetectors): use URLHyperlinkWithMacroDetector.
Comment 1 Alphonse Van Assche CLA 2007-04-10 08:32:14 EDT
Created attachment 63351 [details]
URLHyperlinkWithMacroDetector
Comment 2 Andrew Overholt CLA 2007-04-13 10:24:46 EDT
Created attachment 63753 [details]
new URLHyperlinkWithMacroDetector - extend rather than re-implement

Could we do something like this instead?  Rather than copying and slightly modifying the JFace class, could we extend it like this?  I'm not sure if this makes sense ...

	public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
		IHyperlink[] returned = super.detectHyperlinks(textViewer, region, canShowMultipleHyperlinks);
		
		if (returned.length > 0) {
		IHyperlink hyperlink = returned[0];
			if (hyperlink instanceof URLHyperlink) {
				URLHyperlink urlHyperlink = (URLHyperlink) hyperlink;
				String newURLString = resolveDefinesInURL(urlHyperlink.getURLString());
				return new IHyperlink[] {new URLHyperlink(urlHyperlink.getHyperlinkRegion(), newURLString)};
			}
		}
		return returned;
	}
Comment 3 Alphonse Van Assche CLA 2007-04-14 07:45:32 EDT
Absolutely that make sense more sense, thanks!
Comment 4 Andrew Overholt CLA 2007-04-16 13:56:45 EDT
Thanks for the patch.  Committed as revision 610.

I've started on a test for this functionality.  If you have time, please take a look at the recently-committed:

org.eclipse.linuxtools.rpm.ui.editor.tests.HyperlinkWithMacroTests.java
Comment 5 Andrew Overholt CLA 2009-01-23 10:25:22 EST
Comment on attachment 63351 [details]
URLHyperlinkWithMacroDetector

Setting iplog flag.