下面列出了怎么用org.eclipse.jface.text.IInformationControlCreator的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Creates a new additional information controller.
*
* @param creator
* the information control creator to be used by this controller
* @param delay
* time in milliseconds after which additional info should be displayed
*/
AdditionalInfoController(IInformationControlCreator creator, int delay)
{
super(creator);
setCloser(new Closer());
fDelay = delay;
setAnchor(ANCHOR_RIGHT);
setFallbackAnchors(new Anchor[] { ANCHOR_RIGHT, ANCHOR_LEFT, ANCHOR_BOTTOM });
/*
* Adjust the location by one pixel towards the proposal popup, so that the single pixel border of the
* additional info popup overlays with the border of the popup. This avoids having a double black line.
*/
int spacing = -1;
setMargins(spacing, spacing); // see also adjustment in #computeLocation
InformationControlReplacer replacer = new InformationControlReplacer(new DefaultPresenterControlCreator());
getInternalAccessor().setInformationControlReplacer(replacer);
}
/**
* Creates the content assistant.
*
* @return the content assistant
*/
private SubjectControlContentAssistant createContentAssistant() {
final SubjectControlContentAssistant contentAssistant = new SubjectControlContentAssistant();
contentAssistant
.setRestoreCompletionProposalSize(CheckstyleUIPlugin.getDefault().getDialogSettings());
IContentAssistProcessor processor = new PropertiesContentAssistProcessor();
contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
contentAssistant.setInformationControlCreator(new IInformationControlCreator() {
/*
* @see IInformationControlCreator#createInformationControl(Shell)
*/
@Override
public IInformationControl createInformationControl(Shell parent) {
return new DefaultInformationControl(parent);
}
});
return contentAssistant;
}
/**
* Creates the content assistant.
*
* @return the content assistant
*/
private SubjectControlContentAssistant createContentAssistant() {
final SubjectControlContentAssistant contentAssistant = new SubjectControlContentAssistant();
contentAssistant
.setRestoreCompletionProposalSize(CheckstyleUIPlugin.getDefault().getDialogSettings());
IContentAssistProcessor processor = new PropertiesContentAssistProcessor();
contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
contentAssistant.setInformationControlCreator(new IInformationControlCreator() {
/*
* @see IInformationControlCreator#createInformationControl(Shell)
*/
@Override
public IInformationControl createInformationControl(Shell parent) {
return new DefaultInformationControl(parent);
}
});
return contentAssistant;
}
/**
* Content assistant
*/
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer)
{
ContentAssistant assistant = new ContentAssistant();
assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
assistant.setContentAssistProcessor(new TLACompletionProcessor(), IDocument.DEFAULT_CONTENT_TYPE);
assistant.setContentAssistProcessor(new PCalCompletionProcessor(), TLAPartitionScanner.TLA_PCAL);
assistant.enableColoredLabels(true);
assistant.enableAutoActivation(true);
assistant.setAutoActivationDelay(500);
assistant.setInformationControlCreator(new IInformationControlCreator() {
public IInformationControl createInformationControl(final Shell parent) {
return new DefaultInformationControl(parent, (DefaultInformationControl.IInformationPresenter) null);
}
});
assistant.setSorter(new ICompletionProposalSorter() {
public int compare(ICompletionProposal p1, ICompletionProposal p2) {
return 0;
}
});
assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
assistant.setContextInformationPopupBackground(TLAEditorActivator.getDefault().getTLAColorProvider().getColor(
TLAColorProvider.CONTENT_ASSIST_BACKGROUND_KEY));
return assistant;
}
@Override
public IInformationControlCreator getInformationPresenterControlCreator() {
return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
fInformationControl= new ChangeHoverInformationControl(parent, true, fOrientation, fPartition, null);
fInformationControl.setHorizontalScrollPixel(fLastScrollIndex);
return fInformationControl;
}
};
}
@Override
public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
return new IInformationControlCreator() {
@Override
public IInformationControl createInformationControl(Shell parent) {
return new DefaultInformationControl(parent, false);
}
};
}
/**
* Delegate method for {@link JavaInformationProvider#getInformationPresenterControlCreator()}
*
* @return the information control creator or null if none is available
* @since 3.4
*/
public IInformationControlCreator getInformationPresenterControlCreator() {
return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell shell) {
return new DefaultInformationControl(shell, true);
}
};
}
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
return new AnnotationInformationControl(parent, EditorsUI.getTooltipAffordanceString()) {
@Override
public IInformationControlCreator getInformationPresenterControlCreator() {
return fPresenterControlCreator;
}
};
}
public IInformationControlCreator getHoverControlCreator()
{
if (activeTextHover instanceof ITextHoverExtension)
{
return ((ITextHoverExtension) activeTextHover).getHoverControlCreator();
}
return new IInformationControlCreator()
{
public IInformationControl createInformationControl(Shell parent)
{
return createTextHoverInformationControl(parent, EditorsUI.getTooltipAffordanceString());
}
};
}
@Override
public IInformationControlCreator getInformationControlCreator() {
if(informationControlCreator == null) {
informationControlCreator = new BrowserControlCreator();
}
return informationControlCreator;
}
protected IInformationControlCreator getInformationPresenterControlCreator(
@SuppressWarnings("unused") ISourceViewer sourceViewer) {
return new IInformationControlCreator() {
@Override
public IInformationControl createInformationControl(Shell parent) {
return new DefaultInformationControl(parent, true);
}
};
}
/**
* getInformationPresenterControlCreator
*
* @param sourceViewer
* @return
*/
private IInformationControlCreator getInformationPresenterControlCreator(ISourceViewer sourceViewer)
{
return new IInformationControlCreator()
{
public IInformationControl createInformationControl(Shell parent)
{
return new DefaultInformationControl(parent, true);
}
};
}
@Override
public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
return new DefaultInformationControl(parent, JavaPlugin.getAdditionalInfoAffordanceString());
}
};
}
protected static IInformationControlCreator getHierarchyPresenterControlCreator() {
return new IInformationControlCreator() {
@Override
public IInformationControl createInformationControl(Shell parent) {
int shellStyle = SWT.RESIZE;
int treeStyle = SWT.V_SCROLL | SWT.H_SCROLL;
HierarchyInformationControl hierarchyInformationControl = new HierarchyInformationControl(parent,
shellStyle, treeStyle);
return hierarchyInformationControl;
}
};
}
public IInformationControlCreatorProvider getInformationControlCreatorProvider(ITextViewer textViewer,
IRegion hoverRegion) {
if (!IS_JAVA_DEBUG_HOVER_AVAILABLE)
return null;
final JavaDebugHover javaDebugHover = injector.getInstance(JavaDebugHover.class);
final Object hoverInfo = javaDebugHover.getHoverInfo2(textViewer, hoverRegion);
if (hoverInfo == null)
return null;
return new IEObjectHoverProvider.IInformationControlCreatorProvider2() {
@Override
public IInformationControlCreator getHoverControlCreator() {
return javaDebugHover.getHoverControlCreator();
}
@Override
public Object getInfo() {
return hoverInfo;
}
@Override
public IInformationControlCreator getInformationPresenterControlCreator() {
return javaDebugHover.getInformationPresenterControlCreator();
}
};
}
@Override
public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
return new DefaultInformationControl(parent, false);
}
};
}
public IInformationControlCreator getInformationControlCreator
(ISourceViewer sourceViewer) {
return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
return new DefaultInformationControl(parent, presenter);
}
};
}
public IInformationControlCreator getHoverControlCreator( )
{
return new IInformationControlCreator( ) {
public IInformationControl createInformationControl( Shell parent )
{
return new DefaultInformationControl( parent,
EditorsUI.getTooltipAffordanceString( ) );
}
};
}
private IInformationControlCreator getInformationControlCreator() {
return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
return new DefaultInformationControl(parent, JavaPlugin.getAdditionalInfoAffordanceString());
}
};
}
/**
* {@inheritDoc}
*/
@Override
public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
IInformationControlCreator icc = new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
return new DefaultInformationControl(parent, true);
}
};
InformationPresenter ip = new InformationPresenter(icc);
ModulaInformationProvider mip = new ModulaInformationProvider(this);
ip.setInformationProvider(mip, IModulaPartitions.M2_CONTENT_TYPE_DEFAULT);
return ip;
}
public IInformationControlCreator getInformationPresenterControlCreator()
{
if (fPresenterControlCreator == null)
{
fPresenterControlCreator = new PresenterControlCreator(this);
}
return fPresenterControlCreator;
}
@Override
protected void computeInformation() {
Display display = getSubjectControl().getDisplay();
Point mouseLocation = display.getCursorLocation();
mouseLocation = getSubjectControl().toControl(mouseLocation);
// Compute information input
Object info = informationProvider.getInformation(mouseLocation);
// Find an information control creator for the computed information input
IInformationControlCreator customControlCreator = null;
for (ICustomInformationControlCreator controlCreator : customControlCreators) {
if (controlCreator.isSupported(info)) {
customControlCreator = controlCreator;
break;
}
}
setCustomInformationControlCreator(customControlCreator);
// Convert to String for default TextLabelInformationControl
// (Fallback, if no custom control creator has been found)
//if (info != null && customControlCreator == null) {
// info = info.toString();
//}
// Trigger the presentation of the computed information
if(customControlCreator != null){
Rectangle area = informationProvider.getArea(mouseLocation);
setInformation(info, area);
}
}
private IInformationControlCreator getHierarchyPresenterControlCreator() {
return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
int shellStyle= SWT.RESIZE;
int treeStyle= SWT.V_SCROLL | SWT.H_SCROLL;
return new HierarchyInformationControl(parent, shellStyle, treeStyle);
}
};
}
@Override
public IInformationControlCreator getInformationControlCreator() {
Shell shell = getActiveWorkbenchShell();
if (shell == null || !BrowserInformationControl.isAvailable(shell))
return null;
if (tsControlCreator == null) {
PresenterControlCreator presenterControlCreator = new PresenterControlCreator();
tsControlCreator = new HoverControlCreator(presenterControlCreator, true);
}
return tsControlCreator;
}
@Override
public IInformationControlCreator getInformationPresenterControlCreator() {
// Hack: We don't wan't to have auto-enrichment when the mouse moves
// into the hover,
// but we do want F2 to persist the hover. The framework has no way to
// distinguish the
// two requests, so we have to implement this aspect.
for (StackTraceElement element : Thread.currentThread().getStackTrace()) {
if ("canMoveIntoInformationControl".equals(element.getMethodName()) //$NON-NLS-1$
&& "org.eclipse.jface.text.AbstractHoverInformationControlManager".equals(element.getClassName())) //$NON-NLS-1$
return null; // do not enrich bracket hover
}
return super.getInformationPresenterControlCreator();
}
public static SubjectControlContentAssistant createJavaContentAssistant(IContentAssistProcessor processor) {
final SubjectControlContentAssistant contentAssistant= new SubjectControlContentAssistant();
contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
ContentAssistPreference.configure(contentAssistant, JavaPlugin.getDefault().getPreferenceStore());
contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
contentAssistant.setInformationControlCreator(new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
return new DefaultInformationControl(parent, JavaPlugin.getAdditionalInfoAffordanceString());
}
});
return contentAssistant;
}
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
return new AnnotationInformationControl(parent, EditorsUI.getTooltipAffordanceString()) {
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#
* getInformationPresenterControlCreator()
*/
@Override
public IInformationControlCreator getInformationPresenterControlCreator() {
return fPresenterControlCreator;
}
};
}
@Override
public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer)
{
return new IInformationControlCreator()
{
public IInformationControl createInformationControl(Shell parent)
{
return new ThemedInformationControl(parent, SWT.NONE, new HTMLTextPresenter(true));
}
};
}
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
return new AnnotationInformationControl(parent, EditorsUI.getTooltipAffordanceString()) {
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#getInformationPresenterControlCreator()
*/
@Override
public IInformationControlCreator getInformationPresenterControlCreator() {
return fPresenterControlCreator;
}
};
}
@Override
public IInformationControlCreator getInformationPresenterControlCreator() {
if(matchedHover == null) {
return null;
}
return matchedHover.getInformationPresenterControlCreator();
}