use of org.eclipse.jface.text.hyperlink.URLHyperlink in project webtools.sourceediting by eclipse.
the class TaglibHyperlinkDetector method createHyperlink.
/**
* Create the appropriate hyperlink
*
* @param uriString
* @param hyperlinkRegion
* @return IHyperlink
*/
private IHyperlink createHyperlink(String uriString, IRegion hyperlinkRegion, IDocument document, Node node) {
IHyperlink link = null;
if (uriString != null) {
String temp = uriString.toLowerCase();
if (temp.startsWith(HTTP_PROTOCOL)) {
// this is a URLHyperlink since this is a web address
link = new URLHyperlink(hyperlinkRegion, uriString);
} else if (temp.startsWith(JAR_PROTOCOL)) {
// this is a URLFileHyperlink since this is a local address
try {
link = new URLFileRegionHyperlink(hyperlinkRegion, TAG, node.getLocalName(), new URL(uriString)) {
public String getHyperlinkText() {
return JSPUIMessages.CustomTagHyperlink_hyperlinkText;
}
};
} catch (MalformedURLException e) {
Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
}
} else {
// try to locate the file in the workspace
IPath path = new Path(uriString);
if (path.segmentCount() > 1) {
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
if (file.getType() == IResource.FILE && file.isAccessible()) {
if (node != null) {
link = new TLDFileHyperlink(file, TAG, node.getLocalName(), hyperlinkRegion) {
public String getHyperlinkText() {
return JSPUIMessages.TLDHyperlink_hyperlinkText;
}
};
} else {
link = new WorkspaceFileHyperlink(hyperlinkRegion, file) {
public String getHyperlinkText() {
return JSPUIMessages.TLDHyperlink_hyperlinkText;
}
};
}
}
}
}
if (link == null) {
// this is an ExternalFileHyperlink since file does not exist
// in workspace
File externalFile = new File(uriString);
link = new ExternalFileHyperlink(hyperlinkRegion, externalFile) {
public String getHyperlinkText() {
return JSPUIMessages.TLDHyperlink_hyperlinkText;
}
};
}
}
return link;
}
use of org.eclipse.jface.text.hyperlink.URLHyperlink in project webtools.sourceediting by eclipse.
the class XMLHyperlinkDetector method createHyperlink.
/**
* Create the appropriate hyperlink
*
* @param uriString
* @param hyperlinkRegion
* @return IHyperlink
*/
private IHyperlink createHyperlink(String uriString, IRegion hyperlinkRegion, IDocument document, Node node) {
IHyperlink link = null;
if (isHttp(uriString)) {
link = new URLHyperlink(hyperlinkRegion, uriString);
} else {
// try to locate the file in the workspace
File systemFile = getFileFromUriString(uriString);
if (systemFile != null) {
String systemPath = systemFile.getPath();
IFile file = getFile(systemPath);
if (file != null) {
// this is a WorkspaceFileHyperlink since file exists in
// workspace
link = new WorkspaceFileHyperlink(hyperlinkRegion, file);
} else {
// this is an ExternalFileHyperlink since file does not
// exist in workspace
link = new ExternalFileHyperlink(hyperlinkRegion, systemFile);
}
}
}
return link;
}
Aggregations