Eclipse rcp 如何实现内容辅助';Eclipse RCP中的文档弹出窗口
我已经实现了自己的编辑器,并在其中添加了代码完成功能。“我的内容助手”已在源代码查看器配置中注册,如下所示:Eclipse rcp 如何实现内容辅助';Eclipse RCP中的文档弹出窗口,eclipse-rcp,code-completion,eclipse-pde,Eclipse Rcp,Code Completion,Eclipse Pde,我已经实现了自己的编辑器,并在其中添加了代码完成功能。“我的内容助手”已在源代码查看器配置中注册,如下所示: 公共IContentAssistant getContentAssistant(ISourceViewer){ if(助手==null){ 助手=新内容助手(); setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer)); setContentAssistProcessor(getMyAssistPr
公共IContentAssistant getContentAssistant(ISourceViewer){
if(助手==null){
助手=新内容助手();
setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
setContentAssistProcessor(getMyAssistProcessor(),
MyPartitionScanner。所需的分区(用于我的协助);
助理。启用自动激活(真);
助理设置自动激活显示(500);
设置提案人口定位助理(IContentAssistant.PROPOSAL\u OVERLAY);
assistant.setContextInformationPopupOrientation(上面的IContentAssistant.CONTEXT\u信息);
}
返回助理;
}
当我在所需分区内按Ctrl+SPACE时,将显示完成弹出窗口并按预期工作
这是我的问题。。如何实现/注册出现在完成弹出窗口旁边的文档弹出窗口?(例如在java编辑器中)嗯
我自己来回答这个问题;-)
你必须加上这一行
assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
请参阅上面的配置。然后,在创建CompletionProposals时,构造函数的第八个(最后一个)参数additionalProposalInfo是文本,将显示在文档弹出窗口中
new CompletionProposal(replacementString,
replacementOffset,
replacementLength,
cursorPosition,
image,
displayString,
contextInformation,
additionalProposalInfo);
可以找到有关的更多信息
很简单,不是吗。。如果你知道怎么做;) 用于样式化的信息框(与JDT中类似)
htmltextdepender
import org.eclipse.jface.internal.text.html.HTMLTextPresenter;
public class MyConfiguration extends SourceViewerConfiguration {
[...]
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
if (assistant == null) {
[...]
assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
}
return assistant;
}
@Override
public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
return new DefaultInformationControl(parent,new HTMLTextPresenter(false));
}
};
}
}
公共类MyProposal实现ICompletionProposal{
[...]
@凌驾
公共字符串getAdditionalProposalInfo(){
返回“你好,世界!”;
}
}
public class MyProposal implements ICompletionProposal {
[...]
@Override
public String getAdditionalProposalInfo() {
return "<b>Hello</b> <i>World</i>!";
}
}