blob: 1cf7086ce42aaebda921070817b6c724fc003fdb [file] [log] [blame]
nitindd4f81c02005-02-07 23:11:25 +00001package org.eclipse.jst.jsp.ui.internal.hyperlink;
2
3import org.eclipse.jface.text.IRegion;
4import org.eclipse.jface.text.hyperlink.IHyperlink;
nitinde7cdc9f2005-11-03 00:13:58 +00005import org.eclipse.jst.jsp.core.taglib.IJarRecord;
6import org.eclipse.jst.jsp.core.taglib.ITaglibRecord;
7import org.eclipse.jst.jsp.core.taglib.IURLRecord;
nitindd4f81c02005-02-07 23:11:25 +00008
9/**
10 * Hyperlink for taglib files in jars or specified by urls.
11 */
12class 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) : {
nitinde19fe002005-09-15 11:21:47 +000026 IJarRecord record = (IJarRecord) fTaglibRecord;
nitindd4f81c02005-02-07 23:11:25 +000027 fHyperlink = new TaglibJarHyperlink(fRegion, record.getLocation());
28 }
29 break;
30 case (ITaglibRecord.URL) : {
nitinde19fe002005-09-15 11:21:47 +000031 IURLRecord record = (IURLRecord) fTaglibRecord;
nitindd4f81c02005-02-07 23:11:25 +000032 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}