use of org.eclipse.jface.text.information.IInformationProvider in project mylyn.docs by eclipse.
the class InformationPresenterUtil method getHtmlInformationPresenter.
/**
* Get an information presenter to present the provided HTML content. The returned presenter is ready for displaying
* the information, all that is left to do is call {@link InformationPresenter#showInformation()}.
*
* @param viewer
* the viewer for which the information control should be created
* @param constraint
* the size constraint
* @param toolBarManager
* the tool bar manager, or null if there should be none
* @param htmlContent
* the HTML content to be displayed by the information presenter.
* @return the presenter
*/
public static InformationPresenter getHtmlInformationPresenter(ISourceViewer viewer, SizeConstraint constraint, final ToolBarManager toolBarManager, String htmlContent) {
Control control = viewer.getTextWidget();
InformationPresenter presenter = (InformationPresenter) control.getData(DATA_INFORMATION_PRESENTER);
// bug 270059: ensure that the size/positioning math works by specifying the offet of the
// current selection.
int offset = viewer.getSelectedRange().x;
IInformationControlCreator informationControlCreator;
if (presenter == null) {
informationControlCreator = new IInformationControlCreator() {
@SuppressWarnings("deprecation")
public IInformationControl createInformationControl(Shell shell) {
try {
// DefaultInformationControl(Shell parent, ToolBarManager toolBarManager, IInformationPresenter presenter);
return DefaultInformationControl.class.getConstructor(Shell.class, ToolBarManager.class, IInformationPresenter.class).newInstance(shell, toolBarManager, new HtmlTextPresenter());
} catch (NoSuchMethodException e) {
// no way with 3.3 to get V_SCROLL and a ToolBarManager
return new DefaultInformationControl(shell, SWT.RESIZE, SWT.V_SCROLL | SWT.H_SCROLL, new HtmlTextPresenter());
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
};
presenter = new InformationPresenter(informationControlCreator) {
@Override
public IInformationProvider getInformationProvider(String contentType) {
IInformationProvider informationProvider = super.getInformationProvider(contentType);
if (informationProvider == null) {
informationProvider = super.getInformationProvider(IDocument.DEFAULT_CONTENT_TYPE);
}
return informationProvider;
}
};
presenter.install(viewer);
presenter.setAnchor(AbstractInformationControlManager.ANCHOR_BOTTOM);
// default values from AbstractInformationControlManager
presenter.setMargins(6, 6);
presenter.setOffset(offset);
presenter.install(viewer);
final InformationPresenter informationPresenter = presenter;
viewer.getTextWidget().addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
try {
informationPresenter.uninstall();
} catch (Exception e2) {
}
informationPresenter.dispose();
}
});
control.setData(DATA_INFORMATION_PRESENTER, presenter);
control.setData(DATA_INFORMATION_CONTROL_CREATOR, informationControlCreator);
} else {
informationControlCreator = (IInformationControlCreator) control.getData(DATA_INFORMATION_CONTROL_CREATOR);
presenter.disposeInformationControl();
}
presenter.setSizeConstraints(constraint.horizontalWidthInChars, constraint.verticalWidthInChars, constraint.enforceAsMinimumSize, constraint.enforceAsMaximumSize);
InformationProvider informationProvider = new InformationProvider(new org.eclipse.jface.text.Region(offset, 0), htmlContent, informationControlCreator);
for (String contentType : FastMarkupPartitioner.ALL_CONTENT_TYPES) {
presenter.setInformationProvider(informationProvider, contentType);
}
presenter.setInformationProvider(informationProvider, IDocument.DEFAULT_CONTENT_TYPE);
return presenter;
}
use of org.eclipse.jface.text.information.IInformationProvider in project KaiZen-OpenAPI-Editor by RepreZen.
the class JsonSourceViewerConfiguration method getOutlinePresenter.
public IInformationPresenter getOutlinePresenter(ISourceViewer sourceViewer) {
if (informationPresenter == null) {
IInformationControlCreator controlCreator = getOutlineInformationControlCreator();
informationPresenter = new InformationPresenter(controlCreator);
informationPresenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
// Register information provider
IInformationProvider provider = new InformationProvider(controlCreator);
String[] contentTypes = getConfiguredContentTypes(sourceViewer);
for (String contentType : contentTypes) {
informationPresenter.setInformationProvider(provider, contentType);
}
informationPresenter.setSizeConstraints(60, 20, true, true);
}
return informationPresenter;
}
use of org.eclipse.jface.text.information.IInformationProvider in project eclipse.platform by eclipse-platform.
the class AntEditorSourceViewerConfiguration method getInformationPresenter.
@Override
public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
InformationPresenter presenter = new InformationPresenter(getInformationPresenterControlCreator());
presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
IInformationProvider provider = new AntInformationProvider(new XMLTextHover(fEditor));
presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE);
presenter.setInformationProvider(provider, AntEditorPartitionScanner.XML_CDATA);
presenter.setInformationProvider(provider, AntEditorPartitionScanner.XML_COMMENT);
presenter.setInformationProvider(provider, AntEditorPartitionScanner.XML_DTD);
presenter.setInformationProvider(provider, AntEditorPartitionScanner.XML_TAG);
presenter.setSizeConstraints(60, 10, true, true);
return presenter;
}
use of org.eclipse.jface.text.information.IInformationProvider in project xtext-eclipse by eclipse.
the class JvmImplementationOpener method openQuickHierarchy.
protected void openQuickHierarchy(ITextViewer textViewer, IJavaElement element, IRegion region) {
HierarchyInformationPresenter presenter = new HierarchyInformationPresenter((ISourceViewer) textViewer, element, region);
presenter.setDocumentPartitioning(IDocumentExtension3.DEFAULT_PARTITIONING);
presenter.setAnchor(AbstractInformationControlManager.ANCHOR_GLOBAL);
IInformationProvider provider = new JavaElementProvider(null, false);
presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE);
presenter.setInformationProvider(provider, IJavaPartitions.JAVA_DOC);
presenter.setInformationProvider(provider, IJavaPartitions.JAVA_MULTI_LINE_COMMENT);
presenter.setInformationProvider(provider, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT);
presenter.setInformationProvider(provider, IJavaPartitions.JAVA_STRING);
presenter.setInformationProvider(provider, IJavaPartitions.JAVA_CHARACTER);
presenter.setSizeConstraints(50, 20, true, false);
presenter.install(textViewer);
presenter.showInformation();
}
use of org.eclipse.jface.text.information.IInformationProvider in project dbeaver by serge-rider.
the class SQLEditorSourceViewerConfiguration method getInformationPresenter.
@Override
public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
InformationPresenter presenter = new InformationPresenter(getInformationControlCreator(sourceViewer));
presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
// Register information provider
IInformationProvider provider = new SQLInformationProvider(getSQLEditor(), contextInformer);
String[] contentTypes = getConfiguredContentTypes(sourceViewer);
for (String contentType : contentTypes) {
presenter.setInformationProvider(provider, contentType);
}
presenter.setSizeConstraints(60, 10, true, true);
return presenter;
}
Aggregations