use of org.eclipse.jface.text.IInformationControlCreator in project hale by halestudio.
the class SimpleGroovySourceViewerConfiguration method getContentAssistant.
/*
* @see SourceViewerConfiguration#getContentAssistant(ISourceViewer)
*/
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
// if (getEditor() != null) {
//
ContentAssistant assistant = new ContentAssistant();
assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
assistant.enableColoredLabels(true);
IContentAssistProcessor testProcessor = new GroovyASTCompletionProcessor(fCustomCompletions);
assistant.setContentAssistProcessor(testProcessor, IDocument.DEFAULT_CONTENT_TYPE);
// assistant.setRestoreCompletionProposalSize(getSettings("completion_proposal_size")); //$NON-NLS-1$
//
// IContentAssistProcessor javaProcessor= new JavaCompletionProcessor(getEditor(), assistant, IDocument.DEFAULT_CONTENT_TYPE);
// assistant.setContentAssistProcessor(javaProcessor, IDocument.DEFAULT_CONTENT_TYPE);
//
// ContentAssistProcessor singleLineProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT);
// assistant.setContentAssistProcessor(singleLineProcessor, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT);
//
// ContentAssistProcessor stringProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaPartitions.JAVA_STRING);
// assistant.setContentAssistProcessor(stringProcessor, IJavaPartitions.JAVA_STRING);
//
// ContentAssistProcessor multiLineProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaPartitions.JAVA_MULTI_LINE_COMMENT);
// assistant.setContentAssistProcessor(multiLineProcessor, IJavaPartitions.JAVA_MULTI_LINE_COMMENT);
//
// ContentAssistProcessor javadocProcessor= new JavadocCompletionProcessor(getEditor(), assistant);
// assistant.setContentAssistProcessor(javadocProcessor, IJavaPartitions.JAVA_DOC);
//
// ContentAssistPreference.configure(assistant, fPreferenceStore);
//
// assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
// set how to show "additional information" in a completion proposal
assistant.setInformationControlCreator(new IInformationControlCreator() {
@Override
public IInformationControl createInformationControl(Shell parent) {
return new DefaultInformationControl(parent, true);
}
});
return assistant;
// }
// return null;
}
use of org.eclipse.jface.text.IInformationControlCreator in project erlide_eclipse by erlang.
the class AbstractErlangEditor method createPartControl.
@Override
public void createPartControl(final Composite parent) {
super.createPartControl(parent);
final IInformationControlCreator informationControlCreator = getSourceViewerConfiguration().getInformationControlCreator(getSourceViewer());
fInformationPresenter = new InformationPresenter(informationControlCreator);
// sizes: see org.eclipse.jface.text.TextViewer.TEXT_HOVER_*_CHARS
fInformationPresenter.setSizeConstraints(100, 12, true, true);
fInformationPresenter.install(getSourceViewer());
fInformationPresenter.setDocumentPartitioning(getSourceViewerConfiguration().getConfiguredDocumentPartitioning(getSourceViewer()));
}
use of org.eclipse.jface.text.IInformationControlCreator in project cubrid-manager by CUBRID.
the class SQLViewerConfiguration method getRecentlyUsedContentAssistant.
/**
* get recently used content assistant
*
* @param sourceViewer the source viewer to be configured by this
* configuration
* @return a content assistant
*/
public IContentAssistant getRecentlyUsedContentAssistant(ISourceViewer sourceViewer) {
ContentAssistant assistant = new ContentAssistant();
assistant.setInformationControlCreator(new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
DefaultInformationControl control = new DefaultInformationControl(parent);
return control;
}
});
recentlyUsedSQLContentAssistProcessor = new RecentSQLContentAssistProcessor(databaseProvider);
assistant.setContentAssistProcessor(recentlyUsedSQLContentAssistProcessor, IDocument.DEFAULT_CONTENT_TYPE);
return assistant;
}
use of org.eclipse.jface.text.IInformationControlCreator in project eclipse.platform.text by eclipse.
the class FocusedInformationPresenter method openFocusedAnnotationHover.
/**
* Tries show a focused ("sticky") annotation hover.
*
* @param annotationHover the annotation hover to show
* @param line the line for which to show the hover
* @return <code>true</code> if successful, <code>false</code> otherwise
*/
public boolean openFocusedAnnotationHover(IAnnotationHover annotationHover, int line) {
try {
// compute the hover information
Object hoverInfo;
if (annotationHover instanceof IAnnotationHoverExtension) {
IAnnotationHoverExtension extension = (IAnnotationHoverExtension) annotationHover;
ILineRange hoverLineRange = extension.getHoverLineRange(fSourceViewer, line);
if (hoverLineRange == null)
return false;
// allow any number of lines being displayed, as we support scrolling
final int maxVisibleLines = Integer.MAX_VALUE;
hoverInfo = extension.getHoverInfo(fSourceViewer, hoverLineRange, maxVisibleLines);
} else {
hoverInfo = annotationHover.getHoverInfo(fSourceViewer, line);
}
// hover region: the beginning of the concerned line to place the control right over the line
IDocument document = fSourceViewer.getDocument();
int offset = document.getLineOffset(line);
String contentType = TextUtilities.getContentType(document, fSourceViewerConfiguration.getConfiguredDocumentPartitioning(fSourceViewer), offset, true);
IInformationControlCreator controlCreator = null;
if (// this is undocumented, but left here for backwards compatibility
annotationHover instanceof IInformationProviderExtension2)
controlCreator = ((IInformationProviderExtension2) annotationHover).getInformationPresenterControlCreator();
else if (annotationHover instanceof IAnnotationHoverExtension)
controlCreator = ((IAnnotationHoverExtension) annotationHover).getHoverControlCreator();
IInformationProvider informationProvider = new InformationProvider(new Region(offset, 0), hoverInfo, controlCreator);
setOffset(offset);
setAnchor(AbstractInformationControlManager.ANCHOR_RIGHT);
// AnnotationBarHoverManager sets (5,0), minus SourceViewer.GAP_SIZE_1
setMargins(4, 0);
setInformationProvider(informationProvider, contentType);
showInformation();
return true;
} catch (BadLocationException e) {
return false;
}
}
use of org.eclipse.jface.text.IInformationControlCreator in project eclipse.platform.text by eclipse.
the class CompositeInformationControl method createContent.
@Override
public void createContent(Composite parent) {
// TODO maybe use canReuse or canReplace
this.controls = new LinkedHashMap<>();
GridLayout layout = new GridLayout(1, false);
parent.setLayout(layout);
boolean firstControl = true;
for (Entry<ITextHover, IInformationControlCreator> hoverControlCreator : this.creators.entrySet()) {
IInformationControl informationControl = hoverControlCreator.getValue().createInformationControl(parent.getShell());
if (informationControl instanceof AbstractInformationControl) {
List<Control> children = Arrays.asList(((AbstractInformationControl) informationControl).getShell().getChildren());
children.remove(parent);
if (children.size() == 0) {
continue;
}
for (Control control : children) {
control.setParent(parent);
control.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
}
if (!firstControl) {
((GridData) children.get(0).getLayoutData()).verticalIndent = 15;
}
controls.put(hoverControlCreator.getKey(), informationControl);
firstControl = false;
} else {
GenericEditorPlugin.getDefault().getLog().log(new Status(IStatus.WARNING, GenericEditorPlugin.BUNDLE_ID, // $NON-NLS-1$
"Only text hovers producing an AbstractInformationControl can be aggregated; got a " + informationControl.getClass().getSimpleName()));
informationControl.dispose();
}
}
}
Aggregations