下面列出了怎么用org.eclipse.jface.text.DefaultInformationControl的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Creates the content assistant.
*
* @return the content assistant
*/
private SubjectControlContentAssistant createContentAssistant() {
final SubjectControlContentAssistant contentAssistant = new SubjectControlContentAssistant();
contentAssistant
.setRestoreCompletionProposalSize(CheckstyleUIPlugin.getDefault().getDialogSettings());
IContentAssistProcessor processor = new RegExContentAssistProcessor(true);
contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
contentAssistant.setInformationControlCreator(new IInformationControlCreator() {
/*
* @see org.eclipse.jface.text.IInformationControlCreator#
* createInformationControl( org.eclipse.swt.widgets.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 RegExContentAssistProcessor(true);
contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
contentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
contentAssistant.setInformationControlCreator(new IInformationControlCreator() {
/*
* @see org.eclipse.jface.text.IInformationControlCreator# createInformationControl(
* org.eclipse.swt.widgets.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;
}
/**
* 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 RegExContentAssistProcessor(true);
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;
}
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
String tooltipAffordanceString = EditorsUI
.getTooltipAffordanceString();
if (BrowserInformationControl.isAvailable(parent)) {
String font = "org.eclipse.jdt.ui.javadocfont";
BrowserInformationControl iControl = new BrowserInformationControl(
parent, font, false) {
@Override
public IInformationControlCreator getInformationPresenterControlCreator() {
return fInformationPresenterControlCreator;
}
};
addLinkListener(iControl);
return iControl;
} else {
return new DefaultInformationControl(parent,
tooltipAffordanceString);
}
}
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
String tooltipAffordanceString = EditorsUI.getTooltipAffordanceString();
if (BrowserInformationControl.isAvailable(parent)) {
String font = "org.eclipse.jdt.ui.javadocfont"; // FIXME: PreferenceConstants.APPEARANCE_JAVADOC_FONT;
IXtextBrowserInformationControl iControl = new XtextBrowserInformationControl(parent, font,
tooltipAffordanceString) {
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#getInformationPresenterControlCreator()
*/
@Override
public IInformationControlCreator getInformationPresenterControlCreator() {
return fInformationPresenterControlCreator;
}
};
addLinkListener(iControl);
return iControl;
} else {
return new DefaultInformationControl(parent, tooltipAffordanceString);
}
}
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
String tooltipAffordanceString = EditorsUI.getTooltipAffordanceString();
if (BrowserInformationControl.isAvailable(parent)) {
String font = "org.eclipse.jdt.ui.javadocfont";
IXtextBrowserInformationControl iControl = new XbaseInformationControl(parent, font,
tooltipAffordanceString, xbaseHoverConfiguration) {
@Override
public IInformationControlCreator getInformationPresenterControlCreator() {
return fInformationPresenterControlCreator;
}
};
addLinkListener(iControl);
return iControl;
} else {
return new DefaultInformationControl(parent, tooltipAffordanceString);
}
}
/**
* 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 IInformationControl doCreateInformationControl(Shell parent) {
String tooltipAffordanceString = "Press F2 for focus";
if (BrowserInformationControl.isAvailable(parent)) {
String font = JFaceResources.DIALOG_FONT;
BrowserInformationControl iControl = new BrowserInformationControl(
parent, font, tooltipAffordanceString) {
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#
* getInformationPresenterControlCreator()
*/
@Override
public IInformationControlCreator getInformationPresenterControlCreator() {
return fInformationPresenterControlCreator;
}
};
addLinkListener(iControl);
return iControl;
} else {
return new DefaultInformationControl(parent,
tooltipAffordanceString);
}
}
/**
* Install everything necessary to get document folding working and enable
* document folding
*
* @param sourceViewer
*/
private void installProjectionSupport() {
ProjectionViewer projectionViewer = (ProjectionViewer) getSourceViewer();
fProjectionSupport = new ProjectionSupport(projectionViewer, getAnnotationAccess(), getSharedColors());
fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error"); //$NON-NLS-1$
fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); //$NON-NLS-1$
fProjectionSupport.setHoverControlCreator(new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
return new DefaultInformationControl(parent);
}
});
fProjectionSupport.install();
if (isFoldingEnabled()) {
projectionViewer.doOperation(ProjectionViewer.TOGGLE);
}
}
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
String tooltipAffordanceString = EditorsUI.getTooltipAffordanceString();
if (BrowserInformationControl.isAvailable(parent)) {
String font = "org.eclipse.jdt.ui.javadocfont";
boolean areHoverDocsScrollable = true;
// resizable flag of BrowserInformationControl causes the scrollbar to be always
// enabled.
BrowserInformationControl iControl = new BrowserInformationControl(parent, font,
areHoverDocsScrollable) {
@Override
public IInformationControlCreator getInformationPresenterControlCreator() {
return fInformationPresenterControlCreator;
}
};
addLinkListener(iControl);
return iControl;
} else {
return new DefaultInformationControl(parent, tooltipAffordanceString);
}
}
@Override
public IInformationControl doCreateInformationControl(final Shell parent) {
final String tooltipAffordanceString = EditorsUI.getTooltipAffordanceString();
if (BrowserInformationControl.isAvailable(parent)) {
final String font = "org.eclipse.jdt.ui.javadocfont"; // FIXME:
// PreferenceConstants.APPEARANCE_JAVADOC_FONT;
final IXtextBrowserInformationControl iControl =
new GamlInformationControl(parent, font, tooltipAffordanceString) {
};
addLinkListener(iControl);
return iControl;
} else {
return new DefaultInformationControl(parent, tooltipAffordanceString);
}
}
public IInformationControl doCreateInformationControl(Shell parent)
{
if (BrowserInformationControl.isAvailable(parent))
{
ToolBarManager tbm = new ToolBarManager(SWT.FLAT);
CustomBrowserInformationControl iControl = new CustomBrowserInformationControl(parent, null, tbm);
iControl.setBackgroundColor(documentationHover.getBackgroundColor());
iControl.setForegroundColor(documentationHover.getForegroundColor());
documentationHover.populateToolbarActions(tbm, iControl);
tbm.update(true);
documentationHover.installLinkListener(iControl);
return iControl;
}
else
{
return new DefaultInformationControl(parent, true);
}
}
public IInformationControl doCreateInformationControl(Shell parent)
{
if (CustomBrowserInformationControl.isAvailable(parent))
{
CustomBrowserInformationControl iControl = new CustomBrowserInformationControl(parent, null,
EditorsUI.getTooltipAffordanceString())
{
public IInformationControlCreator getInformationPresenterControlCreator()
{
return informationPresenterControlCreator;
}
};
iControl.setBackgroundColor(getBackgroundColor());
iControl.setForegroundColor(getForegroundColor());
return iControl;
}
else
{
// return new ThemedInformationControl(parent, null, EditorsUI.getTooltipAffordanceString());
return new DefaultInformationControl(parent, true);
}
}
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
String tooltipAffordanceString= fAdditionalInfoAffordance ? JavaPlugin.getAdditionalInfoAffordanceString() : EditorsUI.getTooltipAffordanceString();
if (BrowserInformationControl.isAvailable(parent)) {
String font= PreferenceConstants.APPEARANCE_JAVADOC_FONT;
BrowserInformationControl iControl= new BrowserInformationControl(parent, font, tooltipAffordanceString) {
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#getInformationPresenterControlCreator()
*/
@Override
public IInformationControlCreator getInformationPresenterControlCreator() {
return fInformationPresenterControlCreator;
}
};
addLinkListener(iControl);
return iControl;
} else {
return new DefaultInformationControl(parent, tooltipAffordanceString);
}
}
@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
try {
ProjectionViewer projectionViewer = (ProjectionViewer) getSourceViewer();
fProjectionSupport = new ProjectionSupport(projectionViewer, getAnnotationAccess(), getSharedColors());
fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error");
fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning");
fProjectionSupport.setHoverControlCreator(new IInformationControlCreator() {
@Override
public IInformationControl createInformationControl(Shell shell) {
return new DefaultInformationControl(shell);
}
});
fProjectionSupport.install();
if (isFoldingEnabled()) {
projectionViewer.doOperation(ProjectionViewer.TOGGLE);
}
} catch (Exception e) {
Log.log(e);
}
}
/**
* @Override
*/
public IInformationControlCreator getInformationControlCreator( ISourceViewer sourceViewer){
return new IInformationControlCreator() {
public IInformationControl createInformationControl( Shell parent){
return new DefaultInformationControl(parent, getInformationPresenter());
}
};
}
@Override
public IInformationControlCreator getHoverControlCreator() {
return new IInformationControlCreator() {
@Override
public IInformationControl createInformationControl(Shell parent) {
return new DefaultInformationControl(parent, EditorsUI.getTooltipAffordanceString());
}
};
}
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
if (BrowserInformationControl.isAvailable(parent)) {
ToolBarManager tbm = new ToolBarManager(SWT.FLAT);
String font = "org.eclipse.jdt.ui.javadocfont"; // FIXME: mPreferenceConstants.APPEARANCE_JAVADOC_FONT;
IXtextBrowserInformationControl control = new XtextBrowserInformationControl(parent, font, tbm);
configureControl(control, tbm, font);
return control;
} else {
return new DefaultInformationControl(parent,true);
}
}
protected AbstractReusableInformationControlCreator createInformationControlCreator() {
return new AbstractReusableInformationControlCreator() {
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
return new DefaultInformationControl(parent, (IInformationPresenter) null);
}
};
}
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
if (XbaseInformationControl.isAvailable(parent)) {
ToolBarManager tbm = new ToolBarManager(SWT.FLAT);
String font = "org.eclipse.jdt.ui.javadocfont";
IXtextBrowserInformationControl control = new XbaseInformationControl(parent, font, tbm,
xbaseHoverConfiguration);
configureControl(control, tbm, font);
return control;
} else {
return new DefaultInformationControl(parent, true);
}
}
public IInformationControlCreator getInformationControlCreator
(ISourceViewer sourceViewer) {
return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
return new DefaultInformationControl(parent, presenter);
}
};
}
/**
* {@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;
}
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
if (BrowserInformationControl.isAvailable(parent)) {
ToolBarManager tbm = new ToolBarManager(SWT.FLAT);
TypeScriptBrowserInformationControl control = new TypeScriptBrowserInformationControl(
parent, null, tbm);
tbm.update(true);
addLinkListener(control);
return control;
} else {
return new DefaultInformationControl(parent, true);
}
}
@Override
public IInformationControlCreator getHoverControlCreator() {
return new IInformationControlCreator() {
@Override
public IInformationControl createInformationControl(Shell parent) {
return new DefaultInformationControl(parent, EditorsUI.getTooltipAffordanceString());
}
};
}
@Override
public IInformationControlCreator getInformationPresenterControlCreator() {
return new IInformationControlCreator() {
@Override
public IInformationControl createInformationControl(Shell shell) {
return new DefaultInformationControl(shell, true);
}
};
}
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
IPreferenceStore store= JavaScriptPlugin.getDefault().getPreferenceStore();
JavaScriptTextTools textTools= JavaScriptPlugin.getDefault().getJavaTextTools();
IColorManager manager= textTools.getColorManager();
ContentAssistant assistant= new ContentAssistant();
assistant.setContentAssistProcessor(fProcessor, IDocument.DEFAULT_CONTENT_TYPE);
// Register the same processor for strings and single line comments to get code completion at the start of those partitions.
assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVA_STRING);
assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVA_CHARACTER);
assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVA_SINGLE_LINE_COMMENT);
assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT);
assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVASCRIPT_TEMPLATE_LITERAL);
assistant.setContentAssistProcessor(fProcessor, IJavaScriptPartitions.JAVA_DOC);
assistant.enableAutoInsert(store.getBoolean(PreferenceConstants.CODEASSIST_AUTOINSERT));
assistant.enableAutoActivation(store.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION));
assistant.setAutoActivationDelay(store.getInt(PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
assistant.setInformationControlCreator(new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
return new DefaultInformationControl(parent, SWT.NONE, new HTMLTextPresenter(true));
}
});
Color background= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, manager);
assistant.setContextInformationPopupBackground(background);
assistant.setContextSelectorBackground(background);
assistant.setProposalSelectorBackground(background);
Color foreground= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, manager);
assistant.setContextInformationPopupForeground(foreground);
assistant.setContextSelectorForeground(foreground);
assistant.setProposalSelectorForeground(foreground);
return assistant;
}
@Override
public IInformationControlCreator getInformationControlCreator() {
return parent -> {
final IInformationControl control = new DefaultInformationControl(parent, true);
return control;
};
}
public IInformationControlCreator getHoverControlCreator()
{
return new IInformationControlCreator()
{
public IInformationControl createInformationControl(Shell parent)
{
return new DefaultInformationControl(parent, AbstractCommonTextHover.this.getTooltipAffordanceString());
}
};
}