use of org.eclipse.jdt.internal.ui.infoviews.JavadocView in project windup-eclipse-plugin by windup.
the class ControlInformationSupport method addLinkListener.
private static void addLinkListener(final BrowserInformationControl control) {
control.addLocationListener(JavaElementLinks.createLocationListener(new JavaElementLinks.ILinkHandler() {
@Override
public void handleJavadocViewLink(IJavaElement linkTarget) {
control.notifyDelayedInputChange(null);
control.setVisible(false);
control.dispose();
try {
JavadocView view = (JavadocView) JavaPlugin.getActivePage().showView(JavaUI.ID_JAVADOC_VIEW);
view.setInput(linkTarget);
} catch (PartInitException e) {
JavaPlugin.log(e);
}
}
@Override
public void handleInlineJavadocLink(IJavaElement linkTarget) {
JavadocBrowserInformationControlInput hoverInfo = JavadocHover.getHoverInfo(new IJavaElement[] { linkTarget }, null, null, (JavadocBrowserInformationControlInput) control.getInput());
if (control.hasDelayedInputChangeListener())
control.notifyDelayedInputChange(hoverInfo);
else
control.setInput(hoverInfo);
}
@Override
public void handleDeclarationLink(IJavaElement linkTarget) {
control.notifyDelayedInputChange(null);
control.dispose();
// TODO: ME
/*try {
//FIXME: add hover location to editor navigation history?
openDeclaration(linkTarget);
} catch (PartInitException e) {
JavaPlugin.log(e);
} catch (JavaModelException e) {
JavaPlugin.log(e);
}*/
}
@Override
public boolean handleExternalLink(URL url, Display display) {
control.notifyDelayedInputChange(null);
control.dispose();
// Open attached Javadoc links
OpenBrowserUtil.open(url, display);
return true;
}
@Override
public void handleTextSet() {
}
}));
}
use of org.eclipse.jdt.internal.ui.infoviews.JavadocView in project jbosstools-base by jbosstools.
the class ELInfoHover method addLinkListener.
private static void addLinkListener(final BrowserInformationControl control) {
control.addLocationListener(new LocationListener() {
@Override
public void changing(LocationEvent event) {
String loc = event.location;
if ("about:blank".equals(loc)) {
// $NON-NLS-1$
return;
}
event.doit = false;
if (loc.startsWith("about:")) {
// If no base is available, links just won't work.
return;
}
URI uri = null;
try {
uri = new URI(loc);
} catch (URISyntaxException e) {
ElUiPlugin.getDefault().logError(e);
return;
}
String scheme = uri == null ? null : uri.getScheme();
if (JavaElementLinks.JAVADOC_VIEW_SCHEME.equals(scheme)) {
IJavaElement linkTarget = JavaElementLinks.parseURI(uri);
if (linkTarget == null)
return;
handleJavadocViewLink(linkTarget);
} else if (JavaElementLinks.JAVADOC_SCHEME.equals(scheme)) {
IJavaElement linkTarget = JavaElementLinks.parseURI(uri);
if (linkTarget == null)
return;
handleInlineJavadocLink(linkTarget);
} else if (JavaElementLinks.OPEN_LINK_SCHEME.equals(scheme)) {
IJavaElement linkTarget = JavaElementLinks.parseURI(uri);
if (linkTarget == null)
return;
handleDeclarationLink(linkTarget);
} else if (scheme != null && (// $NON-NLS-1$
scheme.toLowerCase().equalsIgnoreCase("http") || scheme.toLowerCase().equalsIgnoreCase("https"))) {
// $NON-NLS-1$
try {
if (handleExternalLink(new URL(loc), event.display, true))
return;
event.doit = true;
} catch (MalformedURLException e) {
ElUiPlugin.getDefault().logError(e);
}
}
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.viewsupport.JavaElementLinks.ILinkHandler#handleJavadocViewLink(org.eclipse.jdt.core.IJavaElement)
*/
public void handleJavadocViewLink(IJavaElement linkTarget) {
control.notifyDelayedInputChange(null);
control.setVisible(false);
control.dispose();
try {
JavadocView view = (JavadocView) JavaPlugin.getActivePage().showView(JavaUI.ID_JAVADOC_VIEW);
view.setInput(linkTarget);
} catch (PartInitException e) {
ElUiPlugin.getDefault().logError(e);
}
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.viewsupport.JavaElementLinks.ILinkHandler#handleInlineJavadocLink(org.eclipse.jdt.core.IJavaElement)
*/
public void handleInlineJavadocLink(IJavaElement linkTarget) {
JavadocBrowserInformationControlInput hoverInfo = JavadocHover.getHoverInfo(new IJavaElement[] { linkTarget }, null, null, (JavadocBrowserInformationControlInput) control.getInput());
if (control.hasDelayedInputChangeListener())
control.notifyDelayedInputChange(hoverInfo);
else
control.setInput(hoverInfo);
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.viewsupport.JavaElementLinks.ILinkHandler#handleDeclarationLink(org.eclipse.jdt.core.IJavaElement)
*/
public void handleDeclarationLink(IJavaElement linkTarget) {
control.notifyDelayedInputChange(null);
// FIXME: should have protocol to hide, rather than dispose
control.dispose();
try {
JavadocHover.openDeclaration(linkTarget);
} catch (PartInitException e) {
ElUiPlugin.getDefault().logError(e);
} catch (JavaModelException e) {
ElUiPlugin.getDefault().logError(e);
}
}
boolean handleExternalLink(URL url, Display display, boolean openInExternalBrowser) {
control.notifyDelayedInputChange(null);
control.dispose();
// Open attached Javadoc links
if (openInExternalBrowser)
OpenBrowserUtil.openExternal(url, display);
else
OpenBrowserUtil.open(url, display);
return true;
}
public void changed(LocationEvent event) {
}
});
}
Aggregations