下面列出了怎么用org.eclipse.jface.text.IInformationControl的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 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;
}
@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";
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);
}
}
@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);
}
}
private IInformationControlCreator getInformationControlCreator() {
return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
return new DefaultInformationControl(parent, JavaPlugin.getAdditionalInfoAffordanceString());
}
};
}
/**
* @Override
*/
public IInformationControlCreator getInformationControlCreator( ISourceViewer sourceViewer){
return new IInformationControlCreator() {
public IInformationControl createInformationControl( Shell parent){
return new DefaultInformationControl(parent, getInformationPresenter());
}
};
}
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
return new AnnotationInformationControl(parent, EditorsUI.getTooltipAffordanceString()) {
@Override
public IInformationControlCreator getInformationPresenterControlCreator() {
return fPresenterControlCreator;
}
};
}
@Override
public boolean canReuse(IInformationControl control) {
if (!super.canReuse(control))
return false;
if (control instanceof IInformationControlExtension4)
((IInformationControlExtension4) control).setStatusText(EditorsUI.getTooltipAffordanceString());
return true;
}
public ConfigureProblemSeverityAction(IJavaProject project, String optionId, boolean isJavadocOption, IInformationControl infoControl) {
super();
fProject= project;
fOptionId= optionId;
fIsJavadocOption= isJavadocOption;
fInfoControl= infoControl;
setImageDescriptor(JavaPluginImages.DESC_ELCL_CONFIGURE_PROBLEM_SEVERITIES);
setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_CONFIGURE_PROBLEM_SEVERITIES);
setToolTipText(JavaHoverMessages.ProblemHover_action_configureProblemSeverity);
}
@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 IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore();
JavaTextTools textTools= JavaPlugin.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, IJavaPartitions.JAVA_STRING);
assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_CHARACTER);
assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT);
assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.JAVA_MULTI_LINE_COMMENT);
assistant.setContentAssistProcessor(fProcessor, IJavaPartitions.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, JavaPlugin.getAdditionalInfoAffordanceString());
}
});
Color background= getColor(store, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND, manager);
assistant.setContextInformationPopupBackground(background);
assistant.setContextSelectorBackground(background);
Color foreground= getColor(store, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND, manager);
assistant.setContextInformationPopupForeground(foreground);
assistant.setContextSelectorForeground(foreground);
return assistant;
}
@Override
public boolean canReuse(IInformationControl control) {
if (!super.canReuse(control))
return false;
if (control instanceof IInformationControlExtension4) {
String tooltipAffordanceString = EditorsUI.getTooltipAffordanceString();
((IInformationControlExtension4) control).setStatusText(tooltipAffordanceString);
}
return true;
}
protected AbstractReusableInformationControlCreator createInformationControlCreator() {
return new AbstractReusableInformationControlCreator() {
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
return new DefaultInformationControl(parent, (IInformationPresenter) null);
}
};
}
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;
}
};
}
@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);
}
};
}
@Override
public IInformationControlCreator getInformationPresenterControlCreator() {
return new IInformationControlCreator() {
/*
* @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
*/
public IInformationControl createInformationControl(Shell parent) {
return new HoverInformationControl(parent, (ToolBarManager) null);
}
};
}
public ConfigureAnnotationsAction(Annotation annotation, IInformationControl infoControl) {
super();
fAnnotation= annotation;
fInfoControl= infoControl;
setImageDescriptor(JavaPluginImages.DESC_ELCL_CONFIGURE_ANNOTATIONS);
setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_CONFIGURE_ANNOTATIONS);
setToolTipText(JavaHoverMessages.AbstractAnnotationHover_action_configureAnnotationPreferences);
}
public IInformationControlCreator getInformationPresenterControlCreator() {
return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
HoverInformationControl mic = new HoverInformationControl(parent, EditorsUI.getTooltipAffordanceString());
IInformationControlCreator creatorWithFocus = mic.getInformationPresenterControlCreator();
return creatorWithFocus.createInformationControl(parent);
}
};
}
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
return new NLSHoverControl(parent, EditorsUI.getTooltipAffordanceString()) {
/*
* @see org.eclipse.jface.text.IInformationControlExtension5#getInformationPresenterControlCreator()
*/
@Override
public IInformationControlCreator getInformationPresenterControlCreator() {
return fPresenterControlCreator;
}
};
}
/**
* {@inheritDoc}
*/
@Override
public IInformationControlCreator getHoverControlCreator() {
if (lastReturnedHover instanceof ITextHoverExtension) {
return ((ITextHoverExtension) lastReturnedHover).getHoverControlCreator();
} else {
return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
return new HoverInformationControl(parent, EditorsUI.getTooltipAffordanceString());
}
};
}
}
/**
* This customization is needed to render the additional proposal
* information in html form properly.
*/
@Override
protected ConfigurableCompletionProposal doCreateProposal(String proposal,
StyledString displayString, Image image, int replacementOffset,
int replacementLength) {
return new ConfigurableCompletionProposal(proposal, replacementOffset,
replacementLength, proposal.length(), image, displayString,
null, null) {
@Override
public IInformationControlCreator getInformationControlCreator() {
return new IInformationControlCreator() {
@Override
public IInformationControl createInformationControl(
Shell parent) {
/**
* These information has been taken from the
* org.eclipse.xtext.ui.editor.hover.html.DefaultEObjectHoverProvider.HoverControlCreator
* class
*/
String font = "org.eclipse.jdt.ui.javadocfont"; //$NON-NLS-1$
String tooltipAffordanceString = EditorsUI
.getTooltipAffordanceString();
return new XtextBrowserInformationControl(parent, font,
tooltipAffordanceString);
}
};
}
};
}