nitind | d4f81c0 | 2005-02-07 23:11:25 +0000 | [diff] [blame] | 1 | package org.eclipse.jst.jsp.ui.internal.hyperlink; |
| 2 | |
| 3 | import org.eclipse.jface.text.IRegion; |
| 4 | import org.eclipse.jface.text.hyperlink.IHyperlink; |
nitind | e7cdc9f | 2005-11-03 00:13:58 +0000 | [diff] [blame] | 5 | import org.eclipse.jst.jsp.core.taglib.IJarRecord; |
| 6 | import org.eclipse.jst.jsp.core.taglib.ITaglibRecord; |
| 7 | import org.eclipse.jst.jsp.core.taglib.IURLRecord; |
nitind | d4f81c0 | 2005-02-07 23:11:25 +0000 | [diff] [blame] | 8 | |
| 9 | /** |
| 10 | * Hyperlink for taglib files in jars or specified by urls. |
| 11 | */ |
| 12 | class TaglibJarUriHyperlink implements IHyperlink { |
| 13 | private IRegion fRegion; |
| 14 | private ITaglibRecord fTaglibRecord; |
| 15 | private IHyperlink fHyperlink; |
| 16 | |
| 17 | public TaglibJarUriHyperlink(IRegion region, ITaglibRecord record) { |
| 18 | fRegion = region; |
| 19 | fTaglibRecord = record; |
| 20 | } |
| 21 | |
| 22 | private IHyperlink getHyperlink() { |
| 23 | if (fHyperlink == null && fTaglibRecord != null) { |
| 24 | switch (fTaglibRecord.getRecordType()) { |
| 25 | case (ITaglibRecord.JAR) : { |
nitind | e19fe00 | 2005-09-15 11:21:47 +0000 | [diff] [blame] | 26 | IJarRecord record = (IJarRecord) fTaglibRecord; |
nitind | d4f81c0 | 2005-02-07 23:11:25 +0000 | [diff] [blame] | 27 | fHyperlink = new TaglibJarHyperlink(fRegion, record.getLocation()); |
| 28 | } |
| 29 | break; |
| 30 | case (ITaglibRecord.URL) : { |
nitind | e19fe00 | 2005-09-15 11:21:47 +0000 | [diff] [blame] | 31 | IURLRecord record = (IURLRecord) fTaglibRecord; |
nitind | d4f81c0 | 2005-02-07 23:11:25 +0000 | [diff] [blame] | 32 | fHyperlink = new URLFileHyperlink(fRegion, record.getURL()); |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | return fHyperlink; |
| 37 | } |
| 38 | |
| 39 | public IRegion getHyperlinkRegion() { |
| 40 | IRegion region = null; |
| 41 | |
| 42 | IHyperlink link = getHyperlink(); |
| 43 | if (link != null) { |
| 44 | region = link.getHyperlinkRegion(); |
| 45 | } |
| 46 | return region; |
| 47 | } |
| 48 | |
| 49 | /* |
| 50 | * (non-Javadoc) |
| 51 | * |
| 52 | * @see org.eclipse.jface.text.hyperlink.IHyperlink#getTypeLabel() |
| 53 | */ |
| 54 | public String getTypeLabel() { |
| 55 | // TODO Auto-generated method stub |
| 56 | return null; |
| 57 | } |
| 58 | |
| 59 | /* |
| 60 | * (non-Javadoc) |
| 61 | * |
| 62 | * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText() |
| 63 | */ |
| 64 | public String getHyperlinkText() { |
| 65 | // TODO Auto-generated method stub |
| 66 | return null; |
| 67 | } |
| 68 | |
| 69 | public void open() { |
| 70 | IHyperlink link = getHyperlink(); |
| 71 | if (link != null) { |
| 72 | link.open(); |
| 73 | } |
| 74 | } |
| 75 | } |